]>
Commit | Line | Data |
---|---|---|
1 | ||
2 | from wxPython.wx import * | |
3 | from wxPython.xrc import * | |
4 | from Main import opj | |
5 | ||
6 | #---------------------------------------------------------------------- | |
7 | ||
8 | RESFILE = opj("data/resource_wdr.xrc") | |
9 | ||
10 | class TestPanel(wxPanel): | |
11 | def __init__(self, parent, log): | |
12 | wxPanel.__init__(self, parent, -1) | |
13 | self.log = log | |
14 | ||
15 | # make the components | |
16 | label = wxStaticText(self, -1, "The lower panel was built from this XML:") | |
17 | label.SetFont(wxFont(12, wxSWISS, wxNORMAL, wxBOLD)) | |
18 | ||
19 | resourceText = open(RESFILE).read() | |
20 | text = wxTextCtrl(self, -1, resourceText, | |
21 | style=wxTE_READONLY|wxTE_MULTILINE) | |
22 | text.SetInsertionPoint(0) | |
23 | ||
24 | line = wxStaticLine(self, -1) | |
25 | ||
26 | # This shows a few different ways to load XML Resources | |
27 | if 0: | |
28 | # XML Resources can be loaded from a file like this: | |
29 | res = wxXmlResource(RESFILE) | |
30 | ||
31 | elif 1: | |
32 | # or from a Virtual FileSystem: | |
33 | wxFileSystem_AddHandler(wxMemoryFSHandler()) | |
34 | wxMemoryFSHandler_AddFile("XRC_Resources/data_file", resourceText) | |
35 | res = wxXmlResource("memory:XRC_Resources/data_file") | |
36 | ||
37 | else: | |
38 | # or from a string, like this: | |
39 | res = wxEmptyXmlResource() | |
40 | res.LoadFromString(resourceText) | |
41 | ||
42 | ||
43 | # Now create a panel from the resource data | |
44 | panel = res.LoadPanel(self, "MyPanel") | |
45 | ||
46 | # and do the layout | |
47 | sizer = wxBoxSizer(wxVERTICAL) | |
48 | sizer.Add(label, 0, wxEXPAND|wxTOP|wxLEFT, 5) | |
49 | sizer.Add(text, 1, wxEXPAND|wxALL, 5) | |
50 | sizer.Add(line, 0, wxEXPAND) | |
51 | sizer.Add(panel, 1, wxEXPAND|wxALL, 5) | |
52 | ||
53 | self.SetSizer(sizer) | |
54 | self.SetAutoLayout(True) | |
55 | ||
56 | ||
57 | #---------------------------------------------------------------------- | |
58 | ||
59 | def runTest(frame, nb, log): | |
60 | win = TestPanel(nb, log) | |
61 | return win | |
62 | ||
63 | #---------------------------------------------------------------------- | |
64 | ||
65 | ||
66 | ||
67 | overview = """ | |
68 | """ | |
69 | ||
70 | ||
71 | ||
72 | if __name__ == '__main__': | |
73 | import sys,os | |
74 | import run | |
75 | run.main(['', os.path.basename(sys.argv[0])]) | |
76 |