]> git.saurik.com Git - wxWidgets.git/blame - wxPython/samples/wxPIA_book/Chapter-18/xrcsample.py
fix building/running of tex2rtf
[wxWidgets.git] / wxPython / samples / wxPIA_book / Chapter-18 / xrcsample.py
CommitLineData
be05b434
RD
1"""
2XRC is an XML-based resource format for wxPython. With it you can
3define the layout of widgets, and then load that XRC at runtime to
4create the layout. There are several GUI designers available that
5understand the XRC format, a simple one called XRCed comes with
6wxPython.
7"""
8
9import wx
10import wx.xrc
11
12
13class MyFrame(wx.Frame):
14 def __init__(self):
15 wx.Frame.__init__(self, None, title="XRC Sample",
16 size=(400,225))
17 res = wx.xrc.XmlResource("xrcsample.xrc")
18 panel = res.LoadPanel(self, "ID_PANEL")
19
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"))
24
25
26 def OnOk(self, evt):
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)
35
36 def OnCancel(self, evt):
37 self.Close()
38
39
40app = wx.PySimpleApp(redirect=True)
41frm = MyFrame()
42frm.Show()
43app.MainLoop()