How do I create a menu bar and attach it to a frame

To create a menu bar, use the wx.MenuBar constructor, which takes no arguments.

wx.MenuBar()

Once the menu bar is created, attach it to a wx.Frame (or a subclass) using the Set-

MenuBar() method. Typically, you would do this inside the_init_() or OnInit()

method of the frame:

menubar = wx.MenuBar() self.SetMenuBar

You don't need to maintain a temporary variable for the menu bar, but doing so will make adding menus to the bar somewhat more straightforward. To get at the menu bar from someplace else in the program, use wx.Frame.GetMenuBar().

Was this article helpful?

0 0

Post a comment