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/file.Append(-1, '&New')file.Append(-1, '&Open')file.Append(-1, '&Save')file.AppendSeparator()imp = wx.Menu()imp.Append(-1, 'Import newsfeed list...')imp.Append(-1, 'Import bookmarks...')imp.Append(-1, 'Import mail...')file.AppendMenu(-1, 'I&mport', imp)quit = wx.MenuItem(file, ID_QUIT, '&Quit\tCtrl+W')quit.SetBitmap(wx.Bitmap('icons/exit.png'))file.AppendItem(quit)self.Bind(wx.EVT_MENU, self.OnQuit, id=ID_QUIT)menubar.Append(file, '&File')self.SetMenuBar(menubar)self.Centre()self.Show(True)def OnQuit(self, event):self.Close()app = wx.App()SubmenuExample(None, -1, 'Submenu')app.MainLoop()file.AppendSeparator()A menu separator is appended with the AppendSeparator() method.imp = wx.Menu()imp.Append(-1, 'Import newsfeed list...')imp.Append(-1, 'Import bookmarks...')imp.Append(-1, 'Import mail...')file.AppendMenu(-1, 'I&mport', imp)Creating a submenu is trivial. First, we create a menu. <strong>The</strong>n we appendmenu items. A submenu is created by calling the AppenMenu() on themenu object.6 de 15 27/04/2008 1:02

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

Saved successfully!

Ooh no, something went wrong!