先来一个初始界面,然后用快捷键F1全屏。
import wx
class KeyEvent(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title)
panel = wx.Panel(self, -1)
panel.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
panel.SetFocus()
self.Centre()
self.Show(True)
def OnKeyDown(self, event):
keycode = event.GetKeyCode()
if keycode == wx.WXK_F1:
self.SetPosition((0,0))
self.SetSize(wx.DisplaySize())
else:
event.Skip()
app = wx.App()
KeyEvent(None, -1, 'keyevent.py')
app.MainLoop()
如果用快捷键f,那么:
import wx
class KeyEvent(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title)
panel = wx.Panel(self, -1)
panel.Bind(wx.EVT_CHAR, self.OnChar)
panel.SetFocus()
self.Centre()
self.Show(True)
def OnChar(self, event):
char = event.GetKeyCode()
if char == 102:
self.SetPosition((0,0))
self.SetSize(wx.DisplaySize())
else:
event.Skip()
app = wx.App()
KeyEvent(None, -1, 'k.py')
app.MainLoop()
阅读(4524) | 评论(0) | 转发(0) |