]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/XML_Resource.py
b300cd8c91fb641404f26bae47fb0c435633f910
[wxWidgets.git] / wxPython / demo / XML_Resource.py
1
2 from wxPython.wx import *
3 from wxPython.xrc import *
4 from Main import opj
5
6 #----------------------------------------------------------------------
7
8 RESFILE = opj("data/resource_wdr.xrc")
9
10 class TestPanel(wxPanel):
11 def __init__(self, parent, log):
12 wxPanel.__init__(self, parent, -1)
13 self.log = log
14
15 # make the components
16 label = wxStaticText(self, -1, "The lower panel was built from this XML:")
17 label.SetFont(wxFont(12, wxSWISS, wxNORMAL, wxBOLD))
18
19 resourceText = open(RESFILE).read()
20 text = wxTextCtrl(self, -1, resourceText,
21 style=wxTE_READONLY|wxTE_MULTILINE)
22 text.SetInsertionPoint(0)
23
24 line = wxStaticLine(self, -1)
25
26 if 0:
27 # XML Resources can be loaded from a file like this:
28 res = wxXmlResource(RESFILE)
29 else:
30 # or from a string, like this:
31 res = wxEmptyXmlResource()
32 res.LoadFromString(resourceText)
33
34 # Now create a panel from the resource data
35 panel = res.LoadPanel(self, "MyPanel")
36
37 # and do the layout
38 sizer = wxBoxSizer(wxVERTICAL)
39 sizer.Add(label, 0, wxEXPAND|wxTOP|wxLEFT, 5)
40 sizer.Add(text, 1, wxEXPAND|wxALL, 5)
41 sizer.Add(line, 0, wxEXPAND)
42 sizer.Add(panel, 1, wxEXPAND|wxALL, 5)
43
44 self.SetSizer(sizer)
45 self.SetAutoLayout(true)
46
47
48 #----------------------------------------------------------------------
49
50 def runTest(frame, nb, log):
51 win = TestPanel(nb, log)
52 return win
53
54 #----------------------------------------------------------------------
55
56
57
58 overview = """
59 """
60
61
62
63 if __name__ == '__main__':
64 import sys,os
65 import run
66 run.main(['', os.path.basename(sys.argv[0])])
67