Hi!
Sorry for my bad english.
Doing some GUI development with wxPython.
wxXMLResource did not support all wxPython controls.
But XRCed is pretty good for GUI layout and sizers.
So i've create .xrc file wich describes
my panel.
Pretended panel view for example:
···
____________________________________
! wxPanel !
! !
! Static text wxTextCtrl !
! Static text1 unknown ctrl !
! !
! ___________________________________!_
what i need is to bind custom control
with 'unknown ctrl' LATER.
(for the sake of simplicity it's wxTextCtrl,really it's wxPopupCtrl )
Problem :
It did not showing on my Panel.
Can someone enlighten me on that tricky matter?
Simple complete example would suffice.
Here is the code:
------start of code------------------------------------
from wxPython.wx import *
from wxPython.xrc import *
import os, sys
class TestPanel(wxPanel):
def __init__(self, parent):
wxPanel.__init__(self, parent, -1)
self.res = wxXmlResource('')
self.res.InitAllHandlers()
self.res.Load(os.path.join(basePath, 'test.xrc'))
self.NewJobPanel=self.res.LoadPanel(self,"NewJobPanel")
# Here is the trouble !
self.res.AttachUnknownControl("Date1",wxTextCtrl(self.NewJobPanel, -1, "Test it out and see", size=(125, -1)))
box=wxBoxSizer(wxVERTICAL)
box.Add(self.NewJobPanel,1,wxEXPAND)
self.SetSizer(box)
self.SetAutoLayout(true)
#----------------------------------------------------------------------
class MyApp(wxApp):
def OnInit(self):
frame = wxFrame(NULL, -1, 'Sample wxFrame')
win = TestPanel(frame)
frame.Show(true)
return true
if __name__=='__main__':
basePath = os.path.dirname(sys.argv[0])
myapp = MyApp(0)
myapp.MainLoop()
------end of code--------------------
file test.xrc:
<?xml version="1.0" ?>
<resource>
<object class="wxPanel" name="NewJobPanel">
<object class="wxStaticBoxSizer">
<label>Enter new Job</label>
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<object class="wxFlexGridSizer">
<cols>2</cols>
<rows>2</rows>
<object class="sizeritem">
<object class="wxStaticText">
<label>Enter Job Description</label>
</object>
</object>
<object class="sizeritem">
<object class="wxTextCtrl" name="JobDescription">
<style>wxTE_MULTILINE</style>
</object>
<flag>wxRIGHT|wxEXPAND</flag>
</object>
<object class="sizeritem">
<object class="wxStaticText">
<label>File name</label>
</object>
</object>
<object class="sizeritem">
<object class="wxBoxSizer">
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<object class="wxTextCtrl" name="UploadFile"/>
<option>1</option>
<flag>wxRIGHT|wxEXPAND</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxButton" name="BUTTON_BROWSE">
<label>Browse...</label>
<size>30,-1d</size>
</object>
</object>
</object>
<flag>wxRIGHT|wxEXPAND</flag>
<border>5</border>
</object>
<vgap>8</vgap>
<growablecols>1</growablecols>
<object class="sizeritem">
<object class="wxStaticText">
<label>date 1</label>
</object>
</object>
<object class="sizeritem">
<object class="unknown" name="Date1"/>
</object>
</object>
<flag>wxEXPAND</flag>
</object>
</object>
</object>
</resource>
------------------end file test.xrc ------------
Thanks in advance.
Igor.