源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

wxPython窗口的继承机制实例分析

  • 时间:2020-08-06 23:08 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:wxPython窗口的继承机制实例分析
本文实例讲述了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): 
  def __init__(self, parent, id=wx.ID_ANY, title=""): 
    super(MyFrame, self).__init__(parent, id , title)  
 
      # Attributes  
    self.panel = wx.Panel(self) 
    self.panel.SetBackgroundColour(wx.BLACK)#设置面板的背景色为黑色,wx.BLACK为大写,在此犯过错 
    self.button = wx.Button(self.panel, label="push me", pos=(50, 50))#一个按钮的属性,按钮的父窗口为panel 
 
if __name__ == "__main__": 
  app = MyApp() 
  app.MainLoop() 
其中的wx.Button函数介绍如下: wx.Button (wxWindow *parent, wxWindowID id, const wxString &label=wxEmptyString, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxButtonNameStr)    Constructor, creating and showing a button. [b]三层窗口框架: [/b]1. frame或dialog 2. panel或notebooks... 3. controls 最后,来张效果图: [img]http://files.jb51.net/file_images/article/201409/2014928112401966.jpg?2014828112418[/img] 希望本文所述对大家的Python程序设计有所帮助。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部