13.07.2015 Views

The wxPython tutorial

The wxPython tutorial

The wxPython tutorial

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Menus and Toolbars in <strong>wxPython</strong>http://www.zetcode.com/wxpython/menustoolbars/vbox.Add(toolbar1, 0, wx.EXPAND)vbox.Add(toolbar2, 0, wx.EXPAND)self.Bind(wx.EVT_TOOL, self.OnExit, id=wx.ID_EXIT)self.SetSizer(vbox)self.Centre()self.Show(True)def OnExit(self, event):self.Close()app = wx.App()Toolbars(None, -1, 'toolbars')app.MainLoop()toolbar1 = wx.ToolBar(self, -1)...toolbar2 = wx.ToolBar(self, -1)We create two toolbar objects. And put them into a vertical box.Figure: toolbarsSometimes we need to create a vertical toolbar. Vertical toolbars areoften seen in graphics applications like Inkscape or Xara Xtreme.#!/usr/bin/python# verticaltoolbar.pyimport wxclass VerticalToolbar(wx.Frame):def __init__(self, parent, id, title):wx.Frame.__init__(self, parent, id, title, size=(240, 300))toolbar = self.CreateToolBar(wx.TB_VERTICAL)toolbar.AddLabelTool(wx.ID_ANY, '', wx.Bitmap('../icons/select.gif'))toolbar.AddLabelTool(wx.ID_ANY, '', wx.Bitmap('../icons/freehand.gif'))toolbar.AddLabelTool(wx.ID_ANY, '', wx.Bitmap('../icons/shapeed.gif'))toolbar.AddLabelTool(wx.ID_ANY, '', wx.Bitmap('../icons/pen.gif'))12 de 15 27/04/2008 1:02

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!