Python – wxPython 中的菜单栏
GUI 中最重要的部分之一是菜单栏,用于在窗口上执行各种操作。在本文中,我们将学习如何创建菜单栏并向其添加菜单项。这可以使用 wx.MenuBar 类中的 MenuBar() 构造函数和 Append()函数来实现。
Syntax for MenuBar() constructor:
Syntax for Append() function:
wx.MenuBar.Append(self, menu, title)
Parameters:
Parameter | Input Type | Description |
---|---|---|
menu | wx.Menu | The menu to add. Do not deallocate this menu after calling Append . |
title | string | The title of the menu, must be non-empty. |
代码示例:
wx.MenuBar(style=0)
输出 :