阅 读 文 章

一個 wxPython 小例子 [完成品 at 4 樓]

[来源:网上转载 (http://www.chinaunix.net) | 作者:网友(eookoo) | 时间:2007-05-27 | 浏览:人次 ]




 flw 回复于:2007-04-07 10:28:42

不错!支持!建议版主加精华。


 eookoo 回复于:2007-04-09 07:35:57

完成品是由 2 樓的 code 改成過來...
如果見到 :  # --- new: ---  or # --- Changed: ---
就是新加入的東西 or 改變過的東西


import wx 
# -------- new: we need os module to handle path, dir stuffs-----------
import os       

# ------- new: make our own id numbers --------------
ID_OPEN = 100      
ID_SAVE = 101   
ID_EXIT = 102
ID_ABOUT = 200

class SimpleEditor(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size = (700, 600))

# ---------------------create a text area ----------------------
self.text = 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 menus
menuFile = wx.Menu()
menuHelp = wx.Menu()

# ------------- Changed: use our own id instead wx.ID_ANY ------------------ 

#menuFile.Append(wx.ID_ANY, '&Open', 'open a file')
#menuFile.Append(wx.ID_ANY, '&Save', 'save the file')

menuFile.Append(ID_OPEN, '&Open', 'open a file')
menuFile.Append(ID_SAVE, '&Save', 'save the file')
# ----------------------------------------------------------------------

# adding a separator to separate the menu list
menuFile.AppendSeparator()

# ------------- Changed: use our own id instead wx.ID_ANY ------------------ 

#menuFile.Append(wx.ID_ANY, 'E&xit', 'terminate the program')
#menuHelp.Append(wx.ID_ANY, 'A&bout', 'info about this program')

menuFile.Append(ID_EXIT, 'E&xit', 'terminate the program')
menuHelp.Append(ID_ABOUT, 'A&bout', 'info about this program')
# -------------------------------------------------------------------------
论坛热门帖子: [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

最新评论 共有0位网友发表了评论

发表评论

评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名:(注册)
密码:
验证码:
匿名发表

网站地图友情连接交流论坛网站投稿广告服务联系我们留言本站长统计
Some rights reserved: www.chmhome.com, 鄂ICP备07010232号 E-mail:chinakafei@live.com,QQ:552766
中国咖啡技术网(Chmhome):国外编程技术书籍,中文编程手册,经典编程文章,交流技术,技术软件下载,计算机论文,毕业论文.