]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxXmlResource.py
1 # 11/22/2003 - Jeff Grimmett (grimmtooth@softhome.net)
3 # o Updated for wx namespace
11 #----------------------------------------------------------------------
13 RESFILE
= opj("data/resource_wdr.xrc")
15 class TestPanel(wx
.Panel
):
16 def __init__(self
, parent
, log
):
17 wx
.Panel
.__init
__(self
, parent
, -1)
21 label
= wx
.StaticText(self
, -1, "The lower panel was built from this XML:")
22 label
.SetFont(wx
.Font(12, wx
.SWISS
, wx
.NORMAL
, wx
.BOLD
))
24 resourceText
= open(RESFILE
).read()
25 text
= wx
.TextCtrl(self
, -1, resourceText
,
26 style
=wx
.TE_READONLY|wx
.TE_MULTILINE
)
27 text
.SetInsertionPoint(0)
29 line
= wx
.StaticLine(self
, -1)
31 # This shows a few different ways to load XML Resources
33 # XML Resources can be loaded from a file like this:
34 res
= xrc
.XmlResource(RESFILE
)
37 # or from a Virtual FileSystem:
38 wx
.FileSystem_AddHandler(wx
.MemoryFSHandler())
39 wx
.MemoryFSHandler_AddFile("XRC_Resources/data_file", resourceText
)
40 res
= xrc
.XmlResource("memory:XRC_Resources/data_file")
43 # or from a string, like this:
44 res
= xrc
.EmptyXmlResource()
45 res
.LoadFromString(resourceText
)
48 # Now create a panel from the resource data
49 panel
= res
.LoadPanel(self
, "MyPanel")
52 sizer
= wx
.BoxSizer(wx
.VERTICAL
)
53 sizer
.Add(label
, 0, wx
.EXPAND|wx
.TOP|wx
.LEFT
, 5)
54 sizer
.Add(text
, 1, wx
.EXPAND|wx
.ALL
, 5)
55 sizer
.Add(line
, 0, wx
.EXPAND
)
56 sizer
.Add(panel
, 1, wx
.EXPAND|wx
.ALL
, 5)
59 self
.SetAutoLayout(True)
62 #----------------------------------------------------------------------
64 def runTest(frame
, nb
, log
):
65 win
= TestPanel(nb
, log
)
68 #----------------------------------------------------------------------
76 if __name__
== '__main__':
79 run
.main(['', os
.path
.basename(sys
.argv
[0])])