dave on Nostr: # 创建一个wxPython程序的窗口 import wx class MyFrame(wx.Frame): """""" def ...
# 创建一个wxPython程序的窗口
import wx
class MyFrame(wx.Frame):
""""""
def __init__(self):
"""Constructor"""
wx.Frame.__init__(self, None, title="My Window")
panel = wx.Panel(self)
btn = wx.Button(panel, label="Close")
btn.Bind(wx.EVT_BUTTON, self.onClose)
def onClose(self, event):
"""Close the frame"""
self.Close()
if __name__ == "__main__":
app = wx.App(False)
frame = MyFrame()
frame.Show()
app.MainLoop()
import wx
class MyFrame(wx.Frame):
""""""
def __init__(self):
"""Constructor"""
wx.Frame.__init__(self, None, title="My Window")
panel = wx.Panel(self)
btn = wx.Button(panel, label="Close")
btn.Bind(wx.EVT_BUTTON, self.onClose)
def onClose(self, event):
"""Close the frame"""
self.Close()
if __name__ == "__main__":
app = wx.App(False)
frame = MyFrame()
frame.Show()
app.MainLoop()