]>
Commit | Line | Data |
---|---|---|
8fa876ca RD |
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 | |
d56cebe7 | 8 | |
6c5ae2d2 | 9 | from Main import opj |
d56cebe7 RD |
10 | |
11 | #---------------------------------------------------------------------- | |
12 | ||
6c5ae2d2 | 13 | RESFILE = opj("data/resource_wdr.xrc") |
d56cebe7 | 14 | |
8fa876ca | 15 | class TestPanel(wx.Panel): |
d56cebe7 | 16 | def __init__(self, parent, log): |
8fa876ca | 17 | wx.Panel.__init__(self, parent, -1) |
d56cebe7 RD |
18 | self.log = log |
19 | ||
20 | # make the components | |
8fa876ca RD |
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)) | |
d56cebe7 | 23 | |
cd834e7b | 24 | resourceText = open(RESFILE).read() |
8fa876ca RD |
25 | text = wx.TextCtrl(self, -1, resourceText, |
26 | style=wx.TE_READONLY|wx.TE_MULTILINE) | |
d56cebe7 RD |
27 | text.SetInsertionPoint(0) |
28 | ||
8fa876ca | 29 | line = wx.StaticLine(self, -1) |
d56cebe7 | 30 | |
bd435982 | 31 | # This shows a few different ways to load XML Resources |
cd834e7b RD |
32 | if 0: |
33 | # XML Resources can be loaded from a file like this: | |
8fa876ca | 34 | res = xrc.XmlResource(RESFILE) |
bd435982 RD |
35 | |
36 | elif 1: | |
37 | # or from a Virtual FileSystem: | |
8fa876ca RD |
38 | wx.FileSystem_AddHandler(wx.MemoryFSHandler()) |
39 | wx.MemoryFSHandler_AddFile("XRC_Resources/data_file", resourceText) | |
40 | res = xrc.XmlResource("memory:XRC_Resources/data_file") | |
bd435982 | 41 | |
cd834e7b RD |
42 | else: |
43 | # or from a string, like this: | |
8fa876ca | 44 | res = xrc.EmptyXmlResource() |
cd834e7b RD |
45 | res.LoadFromString(resourceText) |
46 | ||
bd435982 | 47 | |
cd834e7b | 48 | # Now create a panel from the resource data |
d56cebe7 RD |
49 | panel = res.LoadPanel(self, "MyPanel") |
50 | ||
51 | # and do the layout | |
8fa876ca RD |
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) | |
d56cebe7 RD |
57 | |
58 | self.SetSizer(sizer) | |
1e4a197e | 59 | self.SetAutoLayout(True) |
d56cebe7 RD |
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 | """ | |
cd834e7b RD |
74 | |
75 | ||
cd834e7b RD |
76 | if __name__ == '__main__': |
77 | import sys,os | |
78 | import run | |
79 | run.main(['', os.path.basename(sys.argv[0])]) | |
80 |