Home > Backend Development > Python Tutorial > wxPython框架类和面板类的使用实例

wxPython框架类和面板类的使用实例

WBOY
Release: 2016-06-16 08:41:34
Original
1156 people have browsed it

本文实例讲述了wxPython框架类和面板类的使用方法,分享给大家供大家参考。具体分析如下:

实现代码如下:

import wx  
 
class MyApp(wx.App):  #自定义应用程序类,类中调用自定义的框架类 
  def OnInit(self): 
    self.frame = MyFrame(None, title = "My Main Frame jb51.net") 
    self.SetTopWindow(self.frame) 
    self.frame.Show() 
 
    return True 
 
class MyFrame(wx.Frame): #自定义框架类,自定义的框架类中有一个panel的属性 
  def __init__(self, parent, id=wx.ID_ANY, title=""): 
    super(MyFrame, self).__init__(parent, id ,title) 
 
       # Attributes  
    self.panel = wx.Panel(self) 
 
if __name__ == "__main__": 
  app = MyApp() 
  app.MainLoop()

Copy after login

程序运行效果如下图所示:

希望本文所述对大家的Python程序设计有所帮助。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template