我希望我能正确地理解,你要做一个windows图形用户界面,它包含在菜单中,由一些项目组成!。正如在评论中提到的,我个人使用wxGlage,它是一个用Python编写的GUI设计器,使用流行的GUI工具箱wxPython帮助您创建wxWidgets/wxPython用户界面。目前,它可以生成Python、C++、Perl、Lisp和XRC(WxWistGes)XML资源代码。在
但是,如果您需要使用wxNotebook,通过wxPython为自己编写任何单词,您可以使用this代码:import random
import wx
class TabPanel(wx.Panel):
#
def __init__(self, parent):
""""""
wx.Panel.__init__(self, parent=parent)
colors = ["red", "blue", "gray", "yellow", "green"]
self.SetBackgroundColour(random.choice(colors))
btn = wx.Button(self, label="Press Me")
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(btn, 0, wx.ALL, 10)
self.SetSizer(sizer)
class DemoFrame(wx.Frame):
"""
Frame that holds all other widgets
"""
def __init__(self):
"""Constructor"""
wx.Frame.__init__(self, None, wx.ID_ANY,
"Notebook Tutorial",
size=(600,400)
)
panel = wx.Panel(self)
notebook = wx.Notebook(panel)
tabOne = TabPanel(notebook)
notebook.AddPage(tabOne, "Tab 1")
tabTwo = TabPanel(notebook)
notebook.AddPage(tabTwo, "Tab 2")
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(notebook, 1, wx.ALL|wx.EXPAND, 5)
panel.SetSizer(sizer)
self.Layout()
self.Show()
if __name__ == "__main__":
app = wx.App(False)
frame = DemoFrame()
app.MainLoop()