⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xrcsample.py

📁 wxPython的基本示例程序
💻 PY
字号:
"""XRC is an XML-based resource format for wxPython.  With it you candefine the layout of widgets, and then load that XRC at runtime tocreate the layout.  There are several GUI designers available thatunderstand the XRC format, a simple one called XRCed comes withwxPython."""import wximport wx.xrcclass MyFrame(wx.Frame):    def __init__(self):        wx.Frame.__init__(self, None, title="XRC Sample",                          size=(400,225))        res = wx.xrc.XmlResource("xrcsample.xrc")        panel = res.LoadPanel(self, "ID_PANEL")                self.Bind(wx.EVT_BUTTON, self.OnOk,                  wx.xrc.XRCCTRL(self, "ID_OK"))        self.Bind(wx.EVT_BUTTON, self.OnCancel,                  wx.xrc.XRCCTRL(self, "ID_CANCEL"))    def OnOk(self, evt):        namectrl  = wx.xrc.XRCCTRL(self, "ID_NAME")        name = namectrl.GetValue()        emailctrl = wx.xrc.XRCCTRL(self, "ID_EMAIL")        email = emailctrl.GetValue()        phonectrl = wx.xrc.XRCCTRL(self, "ID_PHONE")        phone = phonectrl.GetValue()        print "You entered:\n  name: %s\n  email: %s\n  phone: %s\n" \              % (name, email, phone)    def OnCancel(self, evt):        self.Close()    app = wx.PySimpleApp(redirect=True)frm = MyFrame()frm.Show()app.MainLoop()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -