Disable PyQt Arrow Key Focus - python

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)

Related

Is there a way to make an invisible button in Tkinter?

I found ways to hide something after pressing a button, but what I would like to do is having an invisible button that can still be pushed. A secret button of some sort, using Tkinter. It doesn't need to do anything yet
You don't need an invisible button to register a secret click Simply bind <1> to the root window and it will register whenever you click on anything (unless you click on some other widget that is listening for that event). You can then check the coordinates of the click to see where the use clicked.

Python [Canvas]: Detect Mouse Button NOT pressed

My question today is, that I'd like to know, if there's a way to detect a mouse button NOT pressed using canvas.bind().
I want to know that, because I want to save data while a button is pressed, and to stop saving data when the button is not pressed anymore.
I want to do this with the left mouse button / ''
If you don't know what I wan't to do; feel free to ask in the comments :/
Detect mouse press and release events. When one of those events occur, start or stop saving as appropriate.
canvas.bind("<Button-1>", start_saving)
canvas.bind("<ButtonRelease-1>", stop_saving)

How to make custom overlay Text window (similar to Tool Tip )

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()

Getting Tkinter listbox item when hit Button-1

After creating a simple window/widget layout with Page (page.sourceforge.net)
I found that the listbox curselection() call returns the proper index when releasing Button-1.
When hit, it returns the previous index (the item which we just leave).
Becasue of some timer activities I'd like to get the clicked index at click-time, instead of release-time. Can somebody help me how could I do that? Thank you
Bind to the event <<ListboxSelect>> instead of <1>, this event will fire after the current selection has been updated.
If you genuinely need for the binding to work literally on a press of the mouse button you will have to rearrange the order of the bind tags for the widget.

How to change my wx.toolbar event?

I have a wx.toolbar with some buttons. One of the buttons makes pan left!
I want to click on the button and while I keep it pressed, the pan left is made.
For now I only saw that the wx.EVT_TOOL only works when mouse left is up.
Is there a way to do what I intend ?
In the toolbar button's event, you should be able to get the state of the mouse via wx.GetMouseState.
Alternatively, you can make your own toolbar with a panel and some wx.Buttons (or other button widgets).

Categories

Resources