]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/wxXmlResource.py
LessTif 0.93 does not hang in wxWindow::ChangeFont as 0.87 did:
[wxWidgets.git] / wxPython / demo / wxXmlResource.py
CommitLineData
d56cebe7
RD
1
2from wxPython.wx import *
3from wxPython.xrc import *
6c5ae2d2 4from Main import opj
d56cebe7
RD
5
6#----------------------------------------------------------------------
7
6c5ae2d2 8RESFILE = opj("data/resource_wdr.xrc")
d56cebe7
RD
9
10class 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
cd834e7b
RD
19 resourceText = open(RESFILE).read()
20 text = wxTextCtrl(self, -1, resourceText,
d56cebe7
RD
21 style=wxTE_READONLY|wxTE_MULTILINE)
22 text.SetInsertionPoint(0)
23
24 line = wxStaticLine(self, -1)
25
bd435982 26 # This shows a few different ways to load XML Resources
cd834e7b
RD
27 if 0:
28 # XML Resources can be loaded from a file like this:
29 res = wxXmlResource(RESFILE)
bd435982
RD
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
cd834e7b
RD
37 else:
38 # or from a string, like this:
39 res = wxEmptyXmlResource()
40 res.LoadFromString(resourceText)
41
bd435982 42
cd834e7b 43 # Now create a panel from the resource data
d56cebe7
RD
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
59def runTest(frame, nb, log):
60 win = TestPanel(nb, log)
61 return win
62
63#----------------------------------------------------------------------
64
65
66
67overview = """
68"""
cd834e7b
RD
69
70
71
72if __name__ == '__main__':
73 import sys,os
74 import run
75 run.main(['', os.path.basename(sys.argv[0])])
76