简体   繁体   English

鼠标按钮前进python

[英]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. 我目前正在尝试编写图像查看器,但是鼠标上的“前进/后退”按钮并未触发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? Python甚至有可能检测到它们吗?

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? 这些按钮称为XButton,可以与PyHook或PyQt挂钩,但是如果我尝试让它们在后台运行,它们会大量滞后,有什么方法可以防止这种情况发生?

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 将wxPython与PyHook结合使用解决了我的问题,因为Tkinter和PyHook造成了巨大的滞后,而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> . 在我的OSX设备上,我有一个总共有五个按钮的Logitech鼠标,第四个按钮和第五个按钮被视为按钮4和5。例如,我可以绑定到<Button-4><Button-5>

That might work for you, or your mouse driver might assign those buttons to something else. 这可能对您有用,或者您的鼠标驱动程序可能会将这些按钮分配给其他按钮。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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