]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxXmlResource.py
Added PyPlot
[wxWidgets.git] / wxPython / demo / wxXmlResource.py
1 # 11/22/2003 - Jeff Grimmett (grimmtooth@softhome.net)
2 #
3 # o Updated for wx namespace
4 #
5
6 import wx
7 import wx.xrc as xrc
8
9 from Main import opj
10
11 #----------------------------------------------------------------------
12
13 RESFILE = opj("data/resource_wdr.xrc")
14
15 class TestPanel(wx.Panel):
16 def __init__(self, parent, log):
17 wx.Panel.__init__(self, parent, -1)
18 self.log = log
19
20 # make the components
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))
23
24 resourceText = open(RESFILE).read()
25 text = wx.TextCtrl(self, -1, resourceText,
26 style=wx.TE_READONLY|wx.TE_MULTILINE)
27 text.SetInsertionPoint(0)
28
29 line = wx.StaticLine(self, -1)
30
31 # This shows a few different ways to load XML Resources
32 if 0:
33 # XML Resources can be loaded from a file like this:
34 res = xrc.XmlResource(RESFILE)
35
36 elif 1:
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")
41
42 else:
43 # or from a string, like this:
44 res = xrc.EmptyXmlResource()
45 res.LoadFromString(resourceText)
46
47
48 # Now create a panel from the resource data
49 panel = res.LoadPanel(self, "MyPanel")
50
51 # and do the layout
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)
57
58 self.SetSizer(sizer)
59 self.SetAutoLayout(True)
60
61
62 #----------------------------------------------------------------------
63
64 def runTest(frame, nb, log):
65 win = TestPanel(nb, log)
66 return win
67
68 #----------------------------------------------------------------------
69
70
71
72 overview = """
73 """
74
75
76 if __name__ == '__main__':
77 import sys,os
78 import run
79 run.main(['', os.path.basename(sys.argv[0])])
80