[英]Using wxPython's FloatCanvas widget, is there a way to get the ControlDown information of the event?
我想知道是否可以從FloatCanvas觸發的EVT_FC_LEFT_UP事件上獲取鍵盤修改器的狀態。
我更願意這樣做,而不必自己為keyUp和keyDown編寫回調。 與讓類成員在整個窗口中跟蹤修飾符狀態相比,我沒有更好的方法來獲取控件狀態。
是否可以在EVT_FC_LEFT_UP回調內部獲取控制鍵的狀態?
wxPython中沒有isKeyDown
類型方法(afaik)
我看到你得到這個的唯一方法是
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
然后在您的wx.EVT_LEFT_UP
事件處理程序中檢查control_pressed
也是在現實生活中(tm)我懷疑您會希望所有這些都不屬於全局變量
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.