]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/XmlResource.py
Cancel the timer and show the main frame immediately if the
[wxWidgets.git] / wxPython / demo / XmlResource.py
CommitLineData
8fa876ca
RD
1
2import wx
3import wx.xrc as xrc
d56cebe7 4
6c5ae2d2 5from Main import opj
d56cebe7
RD
6
7#----------------------------------------------------------------------
8
6c5ae2d2 9RESFILE = opj("data/resource_wdr.xrc")
d56cebe7 10
8fa876ca 11class TestPanel(wx.Panel):
d56cebe7 12 def __init__(self, parent, log):
8fa876ca 13 wx.Panel.__init__(self, parent, -1)
d56cebe7
RD
14 self.log = log
15
16 # make the components
8fa876ca
RD
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))
d56cebe7 19
cd834e7b 20 resourceText = open(RESFILE).read()
8fa876ca
RD
21 text = wx.TextCtrl(self, -1, resourceText,
22 style=wx.TE_READONLY|wx.TE_MULTILINE)
d56cebe7
RD
23 text.SetInsertionPoint(0)
24
8fa876ca 25 line = wx.StaticLine(self, -1)
d56cebe7 26
bd435982 27 # This shows a few different ways to load XML Resources
cd834e7b
RD
28 if 0:
29 # XML Resources can be loaded from a file like this:
8fa876ca 30 res = xrc.XmlResource(RESFILE)
bd435982
RD
31
32 elif 1:
33 # or from a Virtual FileSystem:
8fa876ca
RD
34 wx.FileSystem_AddHandler(wx.MemoryFSHandler())
35 wx.MemoryFSHandler_AddFile("XRC_Resources/data_file", resourceText)
36 res = xrc.XmlResource("memory:XRC_Resources/data_file")
bd435982 37
cd834e7b
RD
38 else:
39 # or from a string, like this:
8fa876ca 40 res = xrc.EmptyXmlResource()
cd834e7b
RD
41 res.LoadFromString(resourceText)
42
bd435982 43
cd834e7b 44 # Now create a panel from the resource data
d56cebe7
RD
45 panel = res.LoadPanel(self, "MyPanel")
46
47 # and do the layout
8fa876ca
RD
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)
d56cebe7
RD
53
54 self.SetSizer(sizer)
1e4a197e 55 self.SetAutoLayout(True)
d56cebe7
RD
56
57
58#----------------------------------------------------------------------
59
60def runTest(frame, nb, log):
61 win = TestPanel(nb, log)
62 return win
63
64#----------------------------------------------------------------------
65
66
67
68overview = """
69"""
cd834e7b
RD
70
71
cd834e7b
RD
72if __name__ == '__main__':
73 import sys,os
74 import run
8eca4fef 75 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
cd834e7b 76