2 from wxPython
.wx
import *
3 from wxPython
.xrc
import *
6 #----------------------------------------------------------------------
8 RESFILE
= opj("data/resource_wdr.xrc")
10 class TestPanel(wxPanel
):
11 def __init__(self
, parent
, log
):
12 wxPanel
.__init
__(self
, parent
, -1)
16 label
= wxStaticText(self
, -1, "The lower panel was built from this XML:")
17 label
.SetFont(wxFont(12, wxSWISS
, wxNORMAL
, wxBOLD
))
19 resourceText
= open(RESFILE
).read()
20 text
= wxTextCtrl(self
, -1, resourceText
,
21 style
=wxTE_READONLY|wxTE_MULTILINE
)
22 text
.SetInsertionPoint(0)
24 line
= wxStaticLine(self
, -1)
27 # XML Resources can be loaded from a file like this:
28 res
= wxXmlResource(RESFILE
)
30 # or from a string, like this:
31 res
= wxEmptyXmlResource()
32 res
.LoadFromString(resourceText
)
34 # Now create a panel from the resource data
35 panel
= res
.LoadPanel(self
, "MyPanel")
38 sizer
= wxBoxSizer(wxVERTICAL
)
39 sizer
.Add(label
, 0, wxEXPAND|wxTOP|wxLEFT
, 5)
40 sizer
.Add(text
, 1, wxEXPAND|wxALL
, 5)
41 sizer
.Add(line
, 0, wxEXPAND
)
42 sizer
.Add(panel
, 1, wxEXPAND|wxALL
, 5)
45 self
.SetAutoLayout(true
)
48 #----------------------------------------------------------------------
50 def runTest(frame
, nb
, log
):
51 win
= TestPanel(nb
, log
)
54 #----------------------------------------------------------------------
63 if __name__
== '__main__':
66 run
.main(['', os
.path
.basename(sys
.argv
[0])])