国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

基于wxpython實現(xiàn)的windows GUI程序?qū)嵗?/h1>
2020-02-23 01:27:38
字體:
供稿:網(wǎng)友

本文實例講述了基于wxpython實現(xiàn)的windows GUI程序。分享給大家供大家參考。具體如下:

# using a wx.Frame, wx.MenuBar, wx.Menu, wx.Panel, wx.StaticText, wx.Button, # and a wx.BoxSizer to show a rudimentary wxPython Windows GUI application# wxPython package from: http://prdownloads.sourceforge.net/wxpython/# I downloaded: wxPython2.5-win32-ansi-2.5.3.1-py23.exe# if you have not already done so install the Python compiler first# I used Python-2.3.4.exe (the Windows installer package for Python23) # from http://www.python.org/2.3.4/# tested with Python23   vegaseat   24jan2005import wxclass Frame1(wx.Frame):  # create a simple windows frame (sometimes called form)  # pos=(ulcX,ulcY) size=(width,height) in pixels  def __init__(self, parent, title):    wx.Frame.__init__(self, parent, -1, title, pos=(150, 150), size=(350, 250))    # create a menubar at the top of the user frame    menuBar = wx.MenuBar()    # create a menu ...     menu = wx.Menu()    # ... add an item to the menu    # /tAlt-X creates an accelerator for Exit (Alt + x keys)    # the third parameter is an optional hint that shows up in     # the statusbar when the cursor moves across this menu item    menu.Append(wx.ID_EXIT, "E&xit/tAlt-X", "Exit the program")    # bind the menu event to an event handler, share QuitBtn event    self.Bind(wx.EVT_MENU, self.OnQuitButton, id=wx.ID_EXIT)    # put the menu on the menubar    menuBar.Append(menu, "&File")    self.SetMenuBar(menuBar)    # create a status bar at the bottom of the frame    self.CreateStatusBar()    # now create a panel (between menubar and statusbar) ...    panel = wx.Panel(self)    # ... put some controls on the panel    text = wx.StaticText(panel, -1, "Hello World!")    text.SetFont(wx.Font(24, wx.SCRIPT, wx.NORMAL, wx.BOLD))    text.SetSize(text.GetBestSize())    quitBtn = wx.Button(panel, -1, "Quit")    messBtn = wx.Button(panel, -1, "Message")    # bind the button events to event handlers    self.Bind(wx.EVT_BUTTON, self.OnQuitButton, quitBtn)    self.Bind(wx.EVT_BUTTON, self.OnMessButton, messBtn)    # use a sizer to layout the controls, stacked vertically    # with a 10 pixel border around each    sizer = wx.BoxSizer(wx.VERTICAL)    sizer.Add(text, 0, wx.ALL, 10)    sizer.Add(quitBtn, 0, wx.ALL, 10)    sizer.Add(messBtn, 0, wx.ALL, 10)    panel.SetSizer(sizer)    panel.Layout()  def OnQuitButton(self, evt):    # event handler for the Quit button click or Exit menu item    print "See you later alligator! (goes to stdout window)"    wx.Sleep(1)  # 1 second to look at message    self.Close()  def OnMessButton(self, evt):    # event handler for the Message button click    self.SetStatusText('101 Different Ways to Spell "Spam"')class wxPyApp(wx.App):  def OnInit(self):    # set the title too    frame = Frame1(None, "wxPython GUI 2")    self.SetTopWindow(frame)    frame.Show(True)    return True# get it going ...app = wxPyApp(redirect=True)app.MainLoop()

希望本文所述對大家的Python程序設(shè)計有所幫助。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表

主站蜘蛛池模板: 中江县| 平武县| 陆川县| 恩施市| 南皮县| 甘谷县| 黄大仙区| 孟州市| 塔河县| 张家口市| 漠河县| 宁强县| 潮安县| 平武县| 连平县| 丰宁| 横峰县| 汝阳县| 济宁市| 红原县| 北川| 临武县| 信宜市| 奉新县| 许昌县| 曲松县| 威远县| 彰化市| 上蔡县| 西城区| 封开县| 阳山县| 安化县| 清苑县| 盘山县| 柏乡县| 巴青县| 宝鸡市| 永泰县| 呼图壁县| 金溪县|