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/Figure: A submenu exampleVarious menu items<strong>The</strong>re are tree kinds of menu items.normal itemcheck itemradio item#!/usr/bin/python# checkmenuitem.pyimport wxID_STAT = 1ID_TOOL = 2class CheckMenuItem(wx.Frame):def __init__(self, parent, id, title):wx.Frame.__init__(self, parent, id, title, size=(350, 250))menubar = wx.MenuBar()file = wx.Menu()view = wx.Menu()self.shst = view.Append(ID_STAT, 'Show statubar', 'Show Statusbar', kind=wx.ITEM_CHself.shtl = view.Append(ID_TOOL, 'Show toolbar', 'Show Toolbar', kind=wx.ITEM_CHECKview.Check(ID_STAT, True)view.Check(ID_TOOL, True)self.Bind(wx.EVT_MENU, self.ToggleStatusBar, id=ID_STAT)self.Bind(wx.EVT_MENU, self.ToggleToolBar, id=ID_TOOL)menubar.Append(file, '&File')menubar.Append(view, '&View')self.SetMenuBar(menubar)self.toolbar = self.CreateToolBar()self.toolbar.AddLabelTool(3, '', wx.Bitmap('icons/quit.png'))self.statusbar = self.CreateStatusBar()self.Centre()self.Show(True)7 de 15 27/04/2008 1:02

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

Saved successfully!

Ooh no, something went wrong!