]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/wxPIA_book/Chapter-18/xrcsample.py
2 XRC is an XML-based resource format for wxPython. With it you can
3 define the layout of widgets, and then load that XRC at runtime to
4 create the layout. There are several GUI designers available that
5 understand the XRC format, a simple one called XRCed comes with
13 class MyFrame(wx
.Frame
):
15 wx
.Frame
.__init
__(self
, None, title
="XRC Sample",
17 res
= wx
.xrc
.XmlResource("xrcsample.xrc")
18 panel
= res
.LoadPanel(self
, "ID_PANEL")
20 self
.Bind(wx
.EVT_BUTTON
, self
.OnOk
,
21 wx
.xrc
.XRCCTRL(self
, "ID_OK"))
22 self
.Bind(wx
.EVT_BUTTON
, self
.OnCancel
,
23 wx
.xrc
.XRCCTRL(self
, "ID_CANCEL"))
27 namectrl
= wx
.xrc
.XRCCTRL(self
, "ID_NAME")
28 name
= namectrl
.GetValue()
29 emailctrl
= wx
.xrc
.XRCCTRL(self
, "ID_EMAIL")
30 email
= emailctrl
.GetValue()
31 phonectrl
= wx
.xrc
.XRCCTRL(self
, "ID_PHONE")
32 phone
= phonectrl
.GetValue()
33 print "You entered:\n name: %s\n email: %s\n phone: %s\n" \
34 % (name
, email
, phone
)
36 def OnCancel(self
, evt
):
40 app
= wx
.PySimpleApp(redirect
=True)