在 Tkinter 中处理触摸屏手势 [英] Handle touchscreen gesture in Tkinter

查看:22
本文介绍了在 Tkinter 中处理触摸屏手势的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将如何在 Tkinter 中安装触摸屏手势处理程序?

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.

如果 Tcl/Tk 没有专门实现它,这甚至可以在 Tkinter 中实现吗?我想要么窗口管理器向客户端窗口发送一些我可以侦听和处理的事件,要么客户端必须向窗口管理器注册特定类型事件的处理程序,但如果无法注册这些处理程序来自 Tkinter,如果 Tcl 不为它们提供接口,我看不出有什么方法可以做到这一点.

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.

推荐答案

Tk 目前不支持复杂的触摸事件,而且 MSDN 对它们的实际外观非常很薄进入事件循环.(这似乎不是您应该查看的内容.)因为 Tk 在非常低的级别拦截该数据,所以整合起来会很棘手.

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.

我不能再追下去了.我可以看到一些代码是如何工作的,但是 MSDN 函数上的示例与 Tk 所做的完全不匹配.两者之间存在整个框架的不匹配.(我也没有支持这些功能的设备;我的触摸设备不运行 Windows,我的 Windows 设备不支持触摸输入.)

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

我们需要的是一个有触摸输入 Win 8 系统的人来运行一个被黑的 Tk 应用程序(Tk_TranslateWinEvent() in win/tkWinX.c将是正确的位置)打印出无法识别的事件.然后我们可以通过触摸事件看到实际通过线路(好吧,通过主消息泵)发生的事情;我们可能希望它们对应于ManipulationStarted, ManipulationUpdatedManipulationCompleted 事件,但希望并不总是足够的.(我们也可能希望这些事件不会通过另一条路线陷入困境.)

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

这篇关于在 Tkinter 中处理触摸屏手势的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆