Tema: Toolbar...
Ver Mensaje Individual
  #2 (permalink)  
Antiguo 30/01/2010, 10:47
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: Toolbar...

Código Python:
Ver original
  1. import wx
  2.  
  3. class SimpleToolBar(wx.Frame):
  4.     def __init__(self, *args, **kwds):
  5.         wx.Frame.__init__(self, *args, **kwds)
  6.  
  7.         #Creamos el toolbar
  8.         toolbar = self.CreateToolBar()
  9.  
  10.         new_tool = toolbar.AddLabelTool(-1, 'Abrir', wx.Bitmap('new.bmp'))
  11.  
  12.         toolbar.AddSeparator()
  13.  
  14.         open_tool = toolbar.AddLabelTool(-1, 'Nuevo', wx.Bitmap('open.bmp'))
  15.  
  16.         self.Bind(wx.EVT_TOOL, self.OnClick, new_tool)
  17.         self.Bind(wx.EVT_TOOL, self.OnClick, open_tool)
  18.  
  19.         toolbar.Realize()
  20.  
  21.     def OnClick(self, event):
  22.         print "Test"
  23.        
  24.  
  25. if __name__ == '__main__':
  26.     app = wx.PySimpleApp()
  27.     frame = SimpleToolBar(None, title="Simple ToolBar Example")
  28.     frame.Show()
  29.     app.MainLoop()
Ejemplo de como funciona un toolbar, ojo yo tengo en la misma carpeta donde se ejecuta, los archivos open.bmp y new.bmp

Edito: Lo mismo pero con clases :P
Código Python:
Ver original
  1. import wx
  2.  
  3. class Frame(wx.Frame):
  4.     def __init__(self, *args, **kwds):
  5.         wx.Frame.__init__(self, *args, **kwds)
  6.  
  7.         #Creamos el toolbar
  8.         toolbar = ToolBar(self)
  9.  
  10. class ToolBar(wx.ToolBar):
  11.     def __init__(self, *args, **kwds):
  12.         wx.ToolBar.__init__(self, *args, **kwds)
  13.         new_tool = self.AddLabelTool(-1, 'Abrir', wx.Bitmap('new.bmp'))
  14.         self.AddSeparator()
  15.         open_tool = self.AddLabelTool(-1, 'Nuevo', wx.Bitmap('open.bmp'))
  16.         self.Bind(wx.EVT_TOOL, self.OnClick, new_tool)
  17.         self.Bind(wx.EVT_TOOL, self.OnClick, open_tool)
  18.         self.Realize()
  19.  
  20.     def OnClick(self, event):
  21.         print "Test"
  22.  
  23. if __name__ == '__main__':
  24.     app = wx.PySimpleApp()
  25.     frame = Frame(None, title="Simple ToolBar Example")
  26.     frame.Show()
  27.     app.MainLoop()

Última edición por razpeitia; 30/01/2010 a las 11:11