]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/XmlResource.py
7 #----------------------------------------------------------------------
9 RESFILE
= opj("data/resource_wdr.xrc")
11 class TestPanel(wx
.Panel
):
12 def __init__(self
, parent
, log
):
13 wx
.Panel
.__init
__(self
, parent
, -1)
17 label
= wx
.StaticText(self
, -1, "The lower panel was built from this XML:")
18 label
.SetFont(wx
.Font(12, wx
.SWISS
, wx
.NORMAL
, wx
.BOLD
))
20 resourceText
= open(RESFILE
).read()
21 text
= wx
.TextCtrl(self
, -1, resourceText
,
22 style
=wx
.TE_READONLY|wx
.TE_MULTILINE
)
23 text
.SetInsertionPoint(0)
25 line
= wx
.StaticLine(self
, -1)
27 # This shows a few different ways to load XML Resources
29 # XML Resources can be loaded from a file like this:
30 res
= xrc
.XmlResource(RESFILE
)
33 # or from a Virtual FileSystem:
34 wx
.FileSystem_AddHandler(wx
.MemoryFSHandler())
35 wx
.MemoryFSHandler_AddFile("XRC_Resources/data_file", resourceText
)
36 res
= xrc
.XmlResource("memory:XRC_Resources/data_file")
39 # or from a string, like this:
40 res
= xrc
.EmptyXmlResource()
41 res
.LoadFromString(resourceText
)
44 # Now create a panel from the resource data
45 panel
= res
.LoadPanel(self
, "MyPanel")
48 sizer
= wx
.BoxSizer(wx
.VERTICAL
)
49 sizer
.Add(label
, 0, wx
.EXPAND|wx
.TOP|wx
.LEFT
, 5)
50 sizer
.Add(text
, 1, wx
.EXPAND|wx
.ALL
, 5)
51 sizer
.Add(line
, 0, wx
.EXPAND
)
52 sizer
.Add(panel
, 1, wx
.EXPAND|wx
.ALL
, 5)
55 self
.SetAutoLayout(True)
58 #----------------------------------------------------------------------
60 def runTest(frame
, nb
, log
):
61 win
= TestPanel(nb
, log
)
64 #----------------------------------------------------------------------
72 if __name__
== '__main__':
75 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])