xrcsample.py
来自「wxPython的基本示例程序」· Python 代码 · 共 44 行
PY
44 行
"""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 + =
减小字号Ctrl + -
显示快捷键?