From the course: Rapid Application Development with Python

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Compose a menu bar

Compose a menu bar - Python Tutorial

From the course: Rapid Application Development with Python

Start my 1-month free trial

Compose a menu bar

- [Instructor] We'll often want to use a menu in an application and have some hotkeys to provide fast selection of key menu items. Let's see how we do this in wxPython. I'll add the Menu bar widget. Because this is all handled within the initialization function, I don't need to use the self prefix on the working variables. Menubar is a wx.MenuBar widget. And I can now start creating the submenu items. Menu_1 is a wx.Menu widget. I'll add four entries to the submenu list, using the append method. M_new is menu_1.Append. Wx.ID_ANY and we'll call this New. M_open equals menu_1.Append. Wx.ID_ANY, Open. M_recent is menu_1.Append, wx.ID_ANY, Recent. And m_quit is menu_1.Append, wx.ID_ANY, and the menu item is Quit\tCtrl+Q. I've kept a handle for each menu item so that each menu selection can have an event handle. Having created the menu, I can add it to the menu bar and give it a top-level name…

Contents