python GUI wxpython窗口演示

import wx
class MyFrame(wx.Frame):
    def __init__(self, parent, title):
        wx.Frame.__init__(self, parent, title = title)
        self.panel = wx.Panel(self)
        self.panel.Bind(wx.EVT_LEFT_UP, self.OnClick)
        self.Show(True)

    def OnClick(self, event):
        posm = event.GetPosition()
        wx.Button(self.panel,label="Hi~~~",pos = (posm.x, posm.y))

if __name__=='__main__':
    app = wx.App()
    frame = MyFrame(None, 'Hello Python')
    app.MainLoop()
程序运行结果
#Filename:helloworldbtn.py
import wx
class Frame1(wx.Frame):
    def __init__(self,superior):
        wx.Frame.__init__(self,parent = superior,title ="Hello World in wxPython")
        panel = wx.Panel(self)
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.text1=wx.TextCtrl(panel,value ="Let's Begin now!!",size =(250,180),style= wx.TE_MULTILINE)
        sizer.Add(self.text1,0,wx.ALIGN_TOP | wx.EXPAND)
        button = wx.Button(panel,label= "Click Me")
        sizer.Add(button)
        panel.SetSizerAndFit(sizer)
        panel.Layout()
        self.Bind(wx.EVT_BUTTON,self.OnClick,button)
        self.Show(True)
    def OnClick(self,text):
        for i in range(3):
            self.text1.AppendText("\nHello,World!"+str(i))
        self.text1.AppendText('\n'+"-"*20)
if __name__=='__main__':
    app = wx.App()
    frame = Frame1(None)
    app.MainLoop()