Ver Mensaje Individual
  #4 (permalink)  
Antiguo 07/03/2013, 23:47
hiramhzr
 
Fecha de Ingreso: enero-2011
Ubicación: En un Cuarto Cubierto de Pasto Verde
Mensajes: 95
Antigüedad: 13 años, 3 meses
Puntos: 3
Respuesta: Wxpython SetFocus, continuar con el siguinete component presionando tecla

Disculpar por el mal tabulado del texto, así lo arrojo al pegar y no me di cuenta.

Gracias por sus respuestas, ya he leído las dos ligas que me proporcionan, pero sigue sin funcionar seguramente estoy haciendo algo mal y me gustaría me pudieran ayudar. Pequeño código de ejemplo que corre, como se podrán dar cuenta el SetFocus() se lo asigno a un campo de texto pero al presionar TAB no avanza, he agregado en la creación del Frame principal la bandera wx.TAB_TRAVERSAL pero sigue sin funcionar.

Código Python:
Ver original
  1. import wx
  2.  
  3. class foco(wx.Frame):
  4.  
  5. #--------------------------------------------------------------------------------
  6. #Constructor principal
  7.     def __init__(self):
  8.         wx.Frame.__init__(self, None, wx.ID_ANY|wx.TAB_TRAVERSAL,
  9.                           "Foco", size=(300, 400),  style= wx.TAB_TRAVERSAL | wx.DEFAULT_FRAME_STYLE)  
  10.         self.InitUI()
  11.         self.Centre()
  12.         self.Show()
  13.  
  14. # Construccion de la GUI
  15.     def InitUI(self):
  16.  
  17.         panel = wx.Panel(self)
  18.  
  19.         vbox = wx.BoxSizer(wx.VERTICAL)
  20.        
  21.         hbox = wx.BoxSizer(wx.HORIZONTAL)
  22.         st1 = wx.StaticText(self,-1,label='Nombre: ')  
  23.         self.tc1 = wx.TextCtrl(self, -1, size=(100, -1))
  24.  
  25.     self.tc1.SetFocus()
  26.  
  27.         hbox.Add(st1)
  28.         hbox.Add(self.tc1, flag = wx.LEFT, border = 10)
  29.         vbox.Add(hbox, flag=wx.LEFT | wx.TOP, border=40)
  30.         vbox.Add((-1, 10))
  31.  
  32.     hbox2 = wx.BoxSizer(wx.HORIZONTAL)
  33.     st2 = wx.StaticText(self,-1, label=u"Nombre 2: ")
  34.         self.tc2 = wx.TextCtrl(self, -1, size=(100,-1))
  35.         hbox2.Add(st2)
  36.         hbox2.Add(self.tc2, flag=wx.LEFT, border=25)
  37.         vbox.Add(hbox2, flag=wx.LEFT | wx.TOP, border=40)
  38.         vbox.Add((-1,10))  
  39.    
  40.     hbox3 = wx.BoxSizer(wx.HORIZONTAL)
  41.     st3 = wx.StaticText(self, -1, label=u"Nombre 3: ")
  42.     self.tc3 = wx.TextCtrl(self, -1, size=(100, -1))
  43.     hbox3.Add(st3)
  44.     hbox3.Add(self.tc3, flag=wx.LEFT, border=20)
  45.     vbox.Add(hbox3, flag=wx.LEFT | wx.TOP | wx.BOTTOM, border=40)
  46.     vbox.Add((-1,10))
  47.  
  48.     panel.SetSizer(vbox)
  49.  
  50. #----------------------------------------------------------------------
  51. # Run the program
  52. if __name__ == "__main__":
  53.     app = wx.App(False)
  54.     frame = foco()
  55.     app.MainLoop()

De ante mano muchas Gracias.

Última edición por hiramhzr; 07/03/2013 a las 23:51 Razón: Mal edición del código