最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501
当前位置: 首页 - 科技 - 知识百科 - 正文

基于wxpython实现的windowsGUI程序实例

来源:懂视网 责编:小采 时间:2020-11-27 14:41:20
文档

基于wxpython实现的windowsGUI程序实例

基于wxpython实现的windowsGUI程序实例:本文实例讲述了基于wxpython实现的windows GUI程序。分享给大家供大家参考。具体如下: # using a wx.Frame, wx.MenuBar, wx.Menu, wx.Panel, wx.StaticText, wx.Button, # and a wx.BoxSizer to show a rudi
推荐度:
导读基于wxpython实现的windowsGUI程序实例:本文实例讲述了基于wxpython实现的windows GUI程序。分享给大家供大家参考。具体如下: # using a wx.Frame, wx.MenuBar, wx.Menu, wx.Panel, wx.StaticText, wx.Button, # and a wx.BoxSizer to show a rudi

本文实例讲述了基于wxpython实现的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 24jan2005
import wx
class 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
 # 	Alt-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	Alt-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程序设计有所帮助。

声明:本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文档

基于wxpython实现的windowsGUI程序实例

基于wxpython实现的windowsGUI程序实例:本文实例讲述了基于wxpython实现的windows GUI程序。分享给大家供大家参考。具体如下: # using a wx.Frame, wx.MenuBar, wx.Menu, wx.Panel, wx.StaticText, wx.Button, # and a wx.BoxSizer to show a rudi
推荐度:
标签: Windows 实例 gui
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top