wxPython:RegisterHotKeyはバグなのか!?
環境依存も否定できないが、動かない。
RegisterHotKeyが成功すれば、Trueを返すらしいので、試して見たところ、Falseしか返ってこない。
Note This function is currently only implemented under Windows. It is used in the Windows CE port for detecting hardware button presses.
だそうです。
■環境
>>動作しません。
>>動作しました。
#! /usr/bin/env python # coding:utf-8 import wx class MyFrame(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title) list = [wx.MOD_ALT, wx.MOD_ALTGR, wx.MOD_CMD, wx.MOD_CONTROL,wx.MOD_SHIFT] ret = False for i in range(1,100): for j in range(1,500): ret = self.RegisterHotKey(1000000, i, j) if ret: print i, j if not ret: self.Close() self.Bind(wx.EVT_HOTKEY, self.OnClose, id=100) self.Centre() self.Show(True) def OnClose(self, evt): self.Close() def main(): app = wx.App(redirect=False) MyFrame(None, -1, 'MyFrame.py') app.MainLoop() if __name__ == "__main__": main()