frame.Show()
app.MainLoop()

-----------------------------------------------------------------------------------------------
中文解釋好難ah......我的中文不太好...sorry.. >_< !!
Hope you guys like it..
[ 本帖最后由 eookoo 于 2007-4-9 08:33 编辑 ]
eookoo 回复于:2007-04-07 08:01:54
這次展示如何加 menu bar, status bar, and menu
import wx
class SimpleEditor(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title)
# ---------------------create a text area ----------------------
self.control = wx.TextCtrl(self, 1, style=wx.TE_MULTILINE)
# ---------------------create a status bar ---------------------
self.CreateStatusBar()
# ---------------------create a menu bar -----------------------
menuBar = wx.MenuBar()
# ---------------------create a menu ---------------------------
# making two new menu
menuFile = wx.Menu()
menuHelp = wx.Menu()
# lets do something with menuFile
# adding 'Open' to menu list
# when mouse move over it, 'open a file' will show up on the status bar
menuFile.Append(wx.ID_ANY, '&Open', 'open a file')
# adding 'Save' to menu list
menuFile.Append(wx.ID_ANY, '&Save', 'save the file')
# adding a separator to separate the menu list
menuFile.AppendSeparator()
# adding 'Exit' to menu list
menuFile.Append(wx.ID_ANY, 'E&xit', 'terminate the program')
# now is menuHelp turn
menuHelp.Append(wx.ID_ANY, 'A&bout', 'info about this program')
# add the menu list we made to menu bar
# This will show 'File' on the menu bar
menuBar.Append(menuFile, '&File')
# This will show 'Help' on the menu bar
menuBar.Append(menuHelp, '&Help')
# Last step, set the menu bar
self.SetMenuBar(menuBar)
if __name__=='__main__':
app = wx.PySimpleApp()
frame = SimpleEditor(None, wx.ID_ANY, 'Simple Editor')
frame.Show()
app.MainLoop()
| 论坛热门帖子: | [lch203] 写得蛮好的linux学习笔记(10-21) [黑马制造] 学习java的30个目标(10-19) [笑傲股林] 做测试半年了,有点迷茫,应该再学些什么提高自己的测试水平和测试能力呢?(10-19) [udp8589] 大家用google的来吱一声? 用百度的~~也来报道下?(10-18) [沂偌掳兆] 本人总结的一些认为C++比较经典的书籍,希望对大家有用(10-18) |
| TAG标签: | 完成 例子 self wx.ID_ANY parent id title 回复 style |
注册
个人空间
