Chinaunix
标题:
[wxPython]键盘事件
[打印本页]
作者:
mystérieux
时间:
2007-08-02 06:26
标题:
[wxPython]键盘事件
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.OnKeyDown)
panel.SetFocus()
self.Centre()
self.Show(True)
def OnKeyDown(self, event):
if event.GetKeyCode() == ord('f'):
if self.GetPosition()==((0,0)):
self.SetPosition((300,300))
self.SetSize((500,300))
else:
self.SetPosition((0,0))
self.SetSize(wx.DisplaySize())
if event.GetKeyCode() == ord('q'):
self.Close()
else:
event.Skip()
app = wx.App()
KeyEvent(None, -1, 'k.py')
app.MainLoop()
本文来自ChinaUnix博客,如果查看原文请点:
http://blog.chinaunix.net/u1/43271/showart_352149.html
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2