简体   繁体   中英

mouse button forward python

I'm currently trying to write an Image Viewer, but the "Forward/Backward" Buttons on the mouse are not triggering any of the possible binds in tkinter.

I tried the binds:

<Key>, <KeyPress>, <ButtonPress>, <Return>

but none of them can detect the mouse clicks on the forward/backward button.

Has Python even the possiblity to detect them?

Edit:

The buttons are called XButtons and are hookable with PyHook or PyQt, but if I try to let them run in the background, they are lagging massively, any way to prevent that?

I'm currently trying to let this script run smoothly in the background without causing extreme lags

Edit:

Using wxPython with PyHook solved my problem, since Tkinter and PyHook is causing huge lags, which don't appear with wxPython

The answer may vary by platform, and also by mouse driver.

On my OSX device where I have a logitech mouse with a total of five buttons, the fourth and fifth buttons are considered buttons 4 and 5. For example, I can bind to <Button-4> and <Button-5> .

That might work for you, or your mouse driver might assign those buttons to something else.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM