#!/usr/bin/python
#coding=utf-8
import wx
import wx.py.images as images #这里用的是wx中的images 而本来是可以使用import images ,因为我没有安装这模块
class Frame(wx.Frame):
def __init__(self,parent,id,title):
wx.Frame.__init__(self,parent,id,title)
#开始在窗口上添加东西
panel = wx.Panel(self)
panel.SetBackgroundColour(“white”)
statusBar = self.CreateStatusBar() #1 创建状态栏
toolbar = self.CreateToolBar() #2 创建工具栏
toolbar.AddSimpleTool(wx.NewId(), images.getPyBitmap(),”New”, “Long help for ‘New'”) #3 给工具栏增加一个工具
toolbar.Realize()
menuBar = wx.MenuBar()
#7 第一个菜单 file
menu1 = wx.Menu()
menuBar.Append(menu1, “&File”)
#6 第二个菜单 edit
menu2 = wx.Menu()
menu2.Append(wx.NewId(), “&Copy”, “Copy in status bar”)
menu2.Append(wx.NewId(), “C&ut”, “”)
menu2.Append(wx.NewId(), “Paste”, “”)
menu2.AppendSeparator()
menu2.Append(wx.NewId(), “&Options…”, “Display Options”)
menuBar.Append(menu2, “&Edit”) # 在菜单栏上附上菜单
self.SetMenuBar(menuBar) # 在框架上附上菜单栏
pass
class App(wx.App):
def OnInit(self):
self.frame = Frame(parent=None,id=-1,title=”a new window with menu”)
self.frame.Show();
self.MainLoop()
return True
if __name__ == “__main__”:
app = App()