cfmonkey的笔记本

[WxPython笔记2] after Hello world

# 2008 . May. 21

import wx

class MyFrame(wx.Frame):
    
    
def __init__(self, title, pos, size):
        wx.Frame.
__init__(self, None, -1, title, pos, size)
        menuFile 
= wx.Menu() 
        menuFile.Append(
1"&About"
        menuFile.AppendSeparator() 
        menuFile.Append(
2"E&xit"
        menuBar 
= wx.MenuBar() 
        menuBar.Append(menuFile, 
"&File"
        self.SetMenuBar(menuBar) 
        self.CreateStatusBar() 
        self.SetStatusText(
"Welcome to wxPython!"
        self.Bind(wx.EVT_MENU, self.OnAbout, id
=1
        self.Bind(wx.EVT_MENU, self.OnQuit, id
=2
        
    
def OnQuit(self, event): 
            self.Close() 
             
    
def OnAbout(self, event): 
            wx.MessageBox(
"This is a wxPython Hello world sample"
                    
"About Hello World", wx.OK | wx.ICON_INFORMATION, self) 
                    

class MyApp(wx.App):
    
    
def OnInit(self):
        self.frame 
= MyFrame('hello world', (5060), (450340))
        self.frame.Show()
        self.SetTopWindow(self.frame)
        
return True
    

if __name__ == '__main__'
    app 
= MyApp(False) 
    app.MainLoop() 
    

Most of the wxPython toolkit is accessed through the wx package which you
access using the import wx statement. Every wxPython program must have
an application object—an instance of  a wx.App subclass that defines an
OnInit() method. Most wxPython programs will have one or more
frames—instances of subclasses of wx.Frame. A frame is the large, movable,
resizeable window-like container that appears on screen, often with a menu,
status bar, tool bars, and other widgets. Control of your program passes to
wxPython when you call your application’s MainLoop() method.

posted on 2008-05-22 00:48 cfmonkey 阅读(284) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


导航

<2008年5月>
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

统计

常用链接

留言簿(2)

随笔档案

搜索

最新评论

阅读排行榜

评论排行榜