先弄個 Hello World 好了...
import wx
app = wx.PySimpleApp() # create 一個 wxPysimpleApp 的實例
frame = wx.Frame(None, -1, "Hello World") # create 一個 wxFrame 的實例, parent = None , id = -1, title = 'Hello World'
frame.Show() # 顯示這個框框
app.MainLoop() # 一定要有這個, 但不知道怎樣 explain.. xP

-----------------------------------------------------------------------------------------------
再來一個最基本 text editor 的例子
# The signature of the wx.Frame constructor is:
# wx.Frame__init__(self, parent, id = -1, title =' ', pos = wx.DeFaultPosition,
size = wx.DeFaultSize, style = wx.DEFAULT_FRAME_STYLE,
name = 'frame')
# id = -1 ( program 會自動給一個 id )
# -1 is same as wx.ID_ANY
# id = wx.ID_ANY ( recommended, because easy for people to read )
import wx
class MainWindow(wx.Frame): # 自己定義一個 class, 繼承了 wx.Frame
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size = (300,200))
self.control = wx.TextCtrl(self, 1, style = wx.TE_MULTILINE) # create 一個 text area
if __name__=='__main__':
app = wx.PySimpleApp()
frame = MainWindow( None, -1, 'Simple Editor')
| 论坛热门帖子: | [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 |
注册
个人空间
