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

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

Jun 16, 2016 am 08:41 AM
wxpython

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

实现代码如下:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

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程序设计有所帮助。

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

Hot Article

Hot tools Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Python GUI programming: Get started quickly and easily create interactive interfaces Python GUI programming: Get started quickly and easily create interactive interfaces Feb 19, 2024 pm 01:24 PM

Python GUI programming: Get started quickly and easily create interactive interfaces

Detailed explanation of the GUI library wxPython in Python Detailed explanation of the GUI library wxPython in Python Jun 09, 2023 pm 10:00 PM

Detailed explanation of the GUI library wxPython in Python

Python GUI Programming: Make your programs stand out Python GUI Programming: Make your programs stand out Feb 19, 2024 pm 08:33 PM

Python GUI Programming: Make your programs stand out

What are the options for GUI libraries in Python? What are the options for GUI libraries in Python? Oct 27, 2023 pm 03:10 PM

What are the options for GUI libraries in Python?

The Art of Python GUI Programming: Creating Beautiful and Easy-to-Use Interfaces The Art of Python GUI Programming: Creating Beautiful and Easy-to-Use Interfaces Feb 19, 2024 pm 05:36 PM

The Art of Python GUI Programming: Creating Beautiful and Easy-to-Use Interfaces

Python GUI programming: from beginner to proficient Python GUI programming: from beginner to proficient Feb 20, 2024 am 10:50 AM

Python GUI programming: from beginner to proficient

Uncover the magical world of Python GUI programming Uncover the magical world of Python GUI programming Feb 20, 2024 am 10:30 AM

Uncover the magical world of Python GUI programming

Explore the endless possibilities of Python GUI programming Explore the endless possibilities of Python GUI programming Feb 19, 2024 pm 12:51 PM

Explore the endless possibilities of Python GUI programming

See all articles