1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| import wx
class FenetreDemandeTouche(wx.Dialog):
def __init__(self, parent):
wx.Dialog.__init__(self, parent, title = u"Selection de la touche",
style = wx.WANTS_CHARS|wx.SYSTEM_MENU|wx.CAPTION | wx.CLOSE_BOX)
panel = wx.Panel(self, -1, style = wx.WANTS_CHARS)
panel.Bind(wx.EVT_CHAR, self.pushOnTouche)
self.ShowModal()
def pushOnTouche(self, event):
print event.GetKeyCode()
class MyFrame(wx.Frame):
def __init__(self ,*args, **kwargs):
wx.Frame.__init__(self, *args, **kwargs)
panel = wx.Panel(self, -1)
btn = wx.Button(panel, -1, label="push me")
self.Bind(wx.EVT_BUTTON, self.OnPushButton, btn)
def OnPushButton(self ,evt):
dialog = FenetreDemandeTouche(self)
evt.Skip()
app = wx.PySimpleApp(redirect=False)
fr = MyFrame(None, -1, title="test")
fr.Show(True)
app.MainLoop() |
Partager