wxPython

作者: fxxtat | 来源:发表于2016-05-26 18:24 被阅读0次

wxPython


hello world

import wx

app = wx.App(False)  # Create a new app, don't redirect stdout/stderr to a window.
frame = wx.Frame(None, wx.ID_ANY, "Hello World") # A Frame is a top-level window.
frame.Show(True)     # Show the frame.
app.MainLoop()
  • app = wx.App(False)
    • 每个wx.App都是一个wxPython的对象
    • False意为 不重定向一个stdout和stderr窗口
  • frame = wx.Frame(None,wx.ID_ANY,"Hello World")
    • 语法:(Parent,Id,Title)
  • frame.Show(True)
    • 显示
  • app.MainLoop()
    • 启动程序

First Step

import wx
class MyFrame(wx.Frame):
    """ We simply derive a new class of Frame. """
    def __init__(self, parent, title):
        wx.Frame.__init__(self, parent, title=title, size=(200,100))
        self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE)
        self.Show(True)

app = wx.App(False)
frame = MyFrame(None, 'Small editor')
app.MainLoop()
  • 复写构造方法

相关文章

网友评论

      本文标题:wxPython

      本文链接:https://www.haomeiwen.com/subject/mocxdttx.html