While designing QListWidget and QListTree item's display I would like to keep the amount of information displayed to a minimum
listItem=QtGui.QListWidgetItem()
listItem.setText("Some short info on item")
Instead I would like to implement a overlay window that would be displayed above the listItem user is interested in (similar to ToolTip widget).
It would be great if the user would simply position the mouse over the QListWidget item and being able to display floating "Info on Item" overlay window by pressing some keyboard shortcut. Press shortcut - window is displayed. Press a shortcut again to hide it. Any ideas how to implement this?
Here is the idea:
Set your key-press event to do something like the following:
QtGui.QToolTip.showText(QtGui.QCursor.pos(),"Your long format text...",None)
and either set a flag to toggle on-off with the same key-press, or for another key-press do:
QtGui.QToolTip.hideText()
Related
So I have used .bind() on all my buttons and basically I would like to see which button is currently 'selected' when I switch between them with tabulator key. I did spend already quite a while on search for solution but didn't found anything useful. I don't know how to grab that moment when after pressing Tab key focus is on a button.
When there is more widgets I can .bind() Tab key to a widget proceeding button to simply just change foreground of a button but this won't work in case when I have only buttons in frame because first button will be omitted and that's not a clean and right solution to my issue.
If I bind Tab key to that button and change foreground then it's changed but after pressing Tab when button was already selected.
I don't know is there any clean solution for that problem or I will have to for frames that have only buttons create some starting_dummy widget that would initiate change for a first button.
Haven't found a way to detect is Tab key focused at this moment on a particular button (like it is with hover and cursor) but I know when it's going to be so I used that and solved case with only buttons in frame. It's based on what I already wrote in the question - I'm binding Tab key with a function to a widget preceding button to change button colour while button is bind to a function that's changing colour back to normal like this:
self.entry.bind("<Tab>", self.focus_in)
self.button.bind('<Tab>', self.focus_out)
def focus_in(self, event):
self.button.configure(fg_color='white')
def focus_out(self, event):
self.button.configure(fg_color='black')
For the case when only widgets in the frame/root are buttons, like in a menu that I got first I focus_set() on the last button and make a functions that circulate colours on and off at on Tab like this:
self.button2.focus_set()
self.button1.bind('<Tab>', self.focus_in)
self.button2.bind('<Tab>', self.focus_out)
def focus_out(self, event):
self.button1.configure(fg_color='white')
self.button2.configure(fg_color='black')
def focus_in(self, event):
self.button1.configure(fg_color='black')
self.button2.configure(fg_color='white')
Whit a custom made buttons it's just matter of replacing fg_color with a image.
If you use a button as an image holder for your logo or so, then just set state='disabled' and it will be omitted.
I have a sort of to-do list app and I would like to make it so that a user can click and drag down a list of checkboxes, toggling their state to be that of the first box clicked. Basically the same as this HTML question here: "Check" Multiple Checkboxes With Click & Drag?.
How would I go about doing this in Qt? I tried subclassing the mouseMoveEvent of a checkbox to get the current mouse state, but that did not work out for a number of reasons (not the least of which is that per the documenation mouseMoveEvents always return Qt.NoButton). I also ran into focus issues, whereby when the first box is clicked it grabs focus until the mouse is let go of, thus blocking signals to the other boxes.
I have a very simple PyQt application with some buttons and a checkbox.
Right now pressing the arrow keys iterates focus over the buttons and the checkbox. I would like to override the arrow keys events and instead have it print which key you pressed, so pressing "right" would print "right" instead of changing the focus to the next component.
It looks like pressing the arrow keys generates a Paint QEvent and not a KeyPress event so they do not get caught.
Any help would be appreciated, thanks!
It is unclear as to exactly what you are trying to achieve, but without any additional information, I would try setting the focus policy of the buttons and checkboxes, e.g.:
button = QtGui.QPushButton('button1')
button.setFocusPolicy(QtCore.Qt.NoFocus)
I am using wxPython to create a taskbar menu. The menu contains some menu items (obviously).
Now I would like to update/change some of these items when a particular item is clicked, while still displaying the menu.
How can I prevent the taskbar menu from disappearing after clicking an item?
The only method I've found that could be useful is wxMenu.UpdateUI(), but that doesn't prevent the menu from disappearing.
Although I never got around to trying it myself, I remember attempting a similar effect with a popup menu & textctrl. You might want to consider trying wx.lib.agw.flatmenu.FlatMenuBar, it provides an event handler OnMenuDismissed(self, event), as well as a few others, which by name appear to be what you need. You would need to create your own OnMenuDismissed() and override the event.
In Tkinter I'm trying to make it so when a command is run a widget is automatically selected, so that a one may bind events to the newly selected widget.
Basically I want it so when I press a button a text widget appears. When it appears normally one would have to click the text widget to facilitate the running of events bound to the text widget. I want that behavior to automatically happen when the user clicks the button. So that one does not have to click the button and then the text widget, but simply the button.
I'd also like it so if one started typing after the button was pressed it would automatically start filling the text widget. Again to cut out having to click on the text widget.
What bit of code does the above?
The terminology which describes what you want is "focus" -- you want to set the keyboard focus to your text widget. To do that you need to use the focus_set() and/or focus_force() methods on the text widget.