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) 
  26         # This shows a few different ways to load XML Resources 
  28             # XML Resources can be loaded from a file like this: 
  29             res 
= wxXmlResource(RESFILE
) 
  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") 
  38             # or from a string, like this: 
  39             res 
= wxEmptyXmlResource() 
  40             res
.LoadFromString(resourceText
) 
  43         # Now create a panel from the resource data 
  44         panel 
= res
.LoadPanel(self
, "MyPanel") 
  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) 
  54         self
.SetAutoLayout(true
) 
  57 #---------------------------------------------------------------------- 
  59 def runTest(frame
, nb
, log
): 
  60     win 
= TestPanel(nb
, log
) 
  63 #---------------------------------------------------------------------- 
  72 if __name__ 
== '__main__': 
  75     run
.main(['', os
.path
.basename(sys
.argv
[0])])