Ver Mensaje Individual
  #2 (permalink)  
Antiguo 31/08/2011, 20:33
Avatar de razpeitia
razpeitia
Moderador
 
Fecha de Ingreso: marzo-2005
Ubicación: Monterrey, México
Mensajes: 7.321
Antigüedad: 19 años, 1 mes
Puntos: 1360
Respuesta: wxWidgets deteccion de tecla

Dependiendo de lo quieras hacer puedes usar shortcuts o puedes usar eventos en el frame.

Código Python:
Ver original
  1. import wx
  2.  
  3. class MyPanel(wx.Panel):
  4.     def __init__(self, *args, **kwargs):
  5.         wx.Panel.__init__(self, *args, **kwargs)
  6.         vbox = wx.BoxSizer(wx.VERTICAL)
  7.        
  8.         label = wx.StaticText(self, label='Label text')
  9.         textbox = wx.TextCtrl(self)
  10.         button = wx.Button(self, label='Button Text')
  11.        
  12.         vbox.Add(label, flag=wx.EXPAND)
  13.         vbox.Add(textbox, flag=wx.EXPAND)
  14.         vbox.Add(button, flag=wx.EXPAND)
  15.        
  16.         self.SetSizer(vbox)
  17.        
  18.        
  19.  
  20. class MyFrame(wx.Frame):
  21.     def __init__(self, *args, **kwargs):
  22.         wx.Frame.__init__(self, *args, **kwargs)
  23.         self.mpanel = MyPanel(self, -1)
  24.         self.Bind(wx.EVT_CHAR_HOOK, self.onHook)
  25.        
  26.     def onHook(self, event):
  27.         if event.GetKeyCode() == wx.WXK_ESCAPE:
  28.             print "ESC"
  29.         else:
  30.             event.Skip()
  31.        
  32.  
  33. if __name__ == '__main__':
  34.     app = wx.App(0)
  35.     mframe = MyFrame(None, -1)
  36.     mframe.Show()
  37.     app.MainLoop()