|

楼主 |
发表于 2020-7-24 17:33:33
|
显示全部楼层
- #!/usr/bin/env python
- import wx
- import images
- class ToolbarFrame(wx.Frame):
- def __init__(self,parent,id):
- wx.Frame.__init__(self,parent,id,'Toolbars',
- size=(300,200))
- panel = wx.Panel(self)
- panel.SetBackgroundColour('White')
- statusBar = self.CreateStatusBar() #1 创建状态栏
- toolbar = self.CreateToolBar() #2 创建工具栏
- toolbar.AddTool(wx.NewId(),images.getNewBitmap(),
- 'New',"Long help for 'New'") #3 给工具栏增加一个工具
- toolbar.Realize() #4 准备显示工具栏
- menuBar = wx.MenuBar() # 创建菜单栏
- #创建两个菜单
- menu1 = wx.Menu()
- menuBar.Append(menu1,'&File')
- menu2 = wx.Menu()
- #6 创建菜单的项目
- menu2.Append(wx.NewId(),'&Copy','Copy in status bar')
- menu2.Append(wx.NewId(),'&Cut','')
- menu2.Append(wx.NewId(),'&Paste','')
- menu2.AppendSeparator()
- menu2.Append(wx.NewId(),'&Options...','Display Options')
- menuBar.Append(menu2,'&Edit') # 在菜单栏上附上菜单
- self.SetMenuBar(menuBar) # 在框架上附上菜单栏
- if __name__ == '__main__':
- app = wx.App()
- frame = ToolbarFrame(parent=None,id=-1)
- frame.Show()
- app.MainLoop()
-
-
复制代码
运行这个代码 |
|