Handle touchscreen gesture in Tkinter

核能气质少年 提交于 2019-12-10 18:43:52

问题


How would I go about installing a handler of touchscreen gestures in Tkinter?

I need to something particularly simple: to increase the font size whenever an 'expand' gesture is detected.

Is this even possible to do in Tkinter if Tcl/Tk doesn't specifically implement it? I suppose that either the window manager sends the client window some event that I could listen for and handle, or the client must register to the window manager a handler for a specific kind of event, but if it isn't possible to register these handlers from Tkinter and if Tcl doesn't provide an interface to them, I'm don't see a way I could do this.


回答1:


Tk doesn't support the complex touch events at the moment, and MSDN is very thin on what they actually look like when they come in over the event loop. (It's not something that you're supposed to look at, it seems.) Because Tk intercepts that data at a very low level, it's going to be tricky to integrate.

I can't chase this further. I can see how some of the code works, but way that the samples on MSDN function doesn't match up at all to what Tk's doing. There's a whole framework's worth of mismatch between the two. (I also don't have a device which would support these features; my touch devices don't run Windows and my Windows devices don't support touch input.)

What we would need is someone with a touch-input Win 8 system to run a Tk app that has been hacked (Tk_TranslateWinEvent() in win/tkWinX.c would be the right spot) to print out unrecognised events. We could then see what actually comes over the wire (well, through the master message pump) with touch events; we might hope that they correspond to things involved in the ManipulationStarted, ManipulationUpdated and ManipulationCompleted events, but hope is not always enough. (We might also hope that the events aren't squirrelled in via another route.)



来源:https://stackoverflow.com/questions/25373458/handle-touchscreen-gesture-in-tkinter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!