[英]Using wxPython's FloatCanvas widget, is there a way to get the ControlDown information of the event?
I am wondering if I can get the keyboard modifiers' status on EVT_FC_LEFT_UP events fired from a FloatCanvas. 我想知道是否可以从FloatCanvas触发的EVT_FC_LEFT_UP事件上获取键盘修改器的状态。
I would prefer to do it without writing callbacks myself for keyUp and keyDown. 我更愿意这样做,而不必自己为keyUp和keyDown编写回调。 I can't see a better method of grabbing the control status, than having a class member keep track of the modifier states over the whole window. 与让类成员在整个窗口中跟踪修饰符状态相比,我没有更好的方法来获取控件状态。
Is it possible to grab the state of the control key inside of the EVT_FC_LEFT_UP callback? 是否可以在EVT_FC_LEFT_UP回调内部获取控制键的状态?
there is no isKeyDown
type method in wxPython (afaik) wxPython中没有isKeyDown
类型方法(afaik)
the only way I can see you getting this is 我看到你得到这个的唯一方法是
control_pressed = False
.....
self.float_canvas.bind(wx.EVT_KEY_DOWN,OnKeyDown)
self.float_canvas.bind(wx.EVT_KEY_DOWN,OnKeyUp)
.....
def OnKeyDown(evt):
global control_pressed
if evt.GetKeyCode() == 117 #(or whatever the code for ctrl is)
control_pressed = True
def OnKeyUp(evt):
global control_pressed
if evt.GetKeyCode() == 117 #(or whatever the code for ctrl is)
control_pressed = False
And then check control_pressed
in your wx.EVT_LEFT_UP
event handler 然后在您的wx.EVT_LEFT_UP
事件处理程序中检查control_pressed
also in real life(tm) I suspect you would want this all in a class not globals 也是在现实生活中(tm)我怀疑您会希望所有这些都不属于全局变量
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.