self.frame.Bind(wx.EVT_CLOSE, self.OnClose)
def OnClose(self, evt):
print 'cannot close'
# dlg = wx.MessageDialog(None, "Is this explanation OK?",
# 'A Message Box',
# wx.YES_NO | wx.ICON_QUESTION)
# retCode = dlg.ShowModal()
# if (retCode == wx.ID_YES):
# self.frame.Destroy()
# print "yes"
# else:
# print "no"
2. 捕捉 wx 快捷鍵 (wx.EVT_HOTKEY) (不能使用 wx.EVT_KEY_DOWN 事件捕捉快捷鍵)
import win32con #for the VK keycodes
def regHotKey(self):
self.hotKeyId = 100
self.frame.RegisterHotKey(
self.hotKeyId, #a unique ID for this hotkey
win32con.MOD_CONTROL + win32con.MOD_SHIFT , #the modifier key
win32con.VK_DELETE) #the key to watch for
self.regHotKey()
self.Bind(wx.EVT_HOTKEY, self.OnClose, id=self.hotKeyId)
3. 捕捉系統快捷鍵
Tim Golden's Python Stuff: Catch system-wide hotkeys
Reference :
关于wxWidgets中的RegisterHotKey不得不说的故事 - 程序、程序及其他 - 博客频道 - CSDN.NET
RegisterHotKey - wxPyWiki
使用热键控制python程序 - Stonelee's Blog
Python - Dictionary full of windows keys
沒有留言:
張貼留言