scrollhandrag keep on pressing after click - python

I added scrollhandrag for my pan tool function with self.setDragMode(QtWidgets.QGraphicsView.ScrollHandDrag). It is working just fine but when I added some in my mouseReleaseEvent to add Ellipse after releasing the mouse, the scrollhandrag function stop working. When I clicked the mouse, it will drag the screen but when I unclicked the mouse, the hand won't open/uncliked and it keeps on dragging the screen. How can I make the scrollhandrag to unclick when I am no longer pressing my mouse without deleting my mouseReleaseEvent?

Related

Detect Non-Standard Mouse Left and Right Scroll Click using Python

I want to read mouse left and right scroll click events and simulate them in Python in windows. I know I can detect and simulate the default ones such as middle mouse button, vertical and horizontal scroll using the virtual-key codes defined here:
https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
However, those do not correspond to the non-standardized so called "Repeat Scroll Left" and "Repeat Scroll Right" buttons on my Razer Basilisk V3 which I can activate by clicking the scroll wheel to the left and right. I have tried the AHK method to detect the key codes here with no luck:
https://superuser.com/a/1154645
How would I detect these click events on windows? Are there virtual-key codes for these buttons? If not how would I detect and simulate these buttons in Python ctypes?

Check if mouse is outside pygame window

I was running a game in pygame, and I discovered a flaw. The way I coded it, if the mouse went outside of the window, the game started to go around in circles. When you get pygame.mouse.get_pos(), it will return the last value the mouse was detected in the window, but other wise no indication that the mouse has left the window. So, is there any way to check if the mouse has stopped hovering over the pygame window, and has left it?
A simple answer to this would be to use the pygame.mouse.get_focused() function. This returns 0 when the mouse isn't focused on the screen. So if you wanted to check if the mouse was outside the window, you could simply do
mouseFocus = pygame.mouse.get_focused()
During the main loop and have an if statement checking if the mouse has left the screen.
if mouseFocus == 0:
print("mouse is out of screen.")
Hope this helps

Right clicking on plot to zoom in Bokeh

I recently started using Bokeh. Overall I am very satisfied. One thing I find annoying though is that it seems I can only play with the left mouse button and need to manually switch tools everytime I want to pan/zoom/etc... It would be great if I could pan with left mouse buttom and zoom in with right mouse button. Is there a way to automatically 'switch' to zoom tool whenever right mouse button held, and switch back when left mouse button held?
Thanks!

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