Added the sample code from wxPython In Action to the samples dir

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42925 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2006-11-01 22:36:23 +00:00
parent bb2775b9e8
commit be05b43451
184 changed files with 9122 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
"""
XRC is an XML-based resource format for wxPython. With it you can
define the layout of widgets, and then load that XRC at runtime to
create the layout. There are several GUI designers available that
understand the XRC format, a simple one called XRCed comes with
wxPython.
"""
import wx
import wx.xrc
class 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()