XRC and dynamically created widgets?
John Salerno
johnjsal at NOSPAMgmail.com
Sun Oct 1 22:26:11 PDT 2006
Ok, I think I asked this question more generally a few days ago, but now
that I have some XRC experience, I will be more specific and hopefully
it will make more sense.
But before I ask, I have one other question. In an example on the
wxPyWiki I saw this kind of code:
def InitFrame(self):
1 self.frame = self.res.LoadFrame(None, "MainFrame")
2 self.panel = xrc.XRCCTRL(self.frame, "MainPanel")
3 self.first_arg = xrc.XRCCTRL(self.panel, "FirstArg")
4 self.second_arg = xrc.XRCCTRL(self.panel, "SecondArg")
5 self.result = xrc.XRCCTRL(self.panel, "Result")
Are lines 2-5 necessary for creating the widgets, or are they there just
so the program will have access to them later? I ran something similar
myself and it seems like the LoadFrame call automatically creates and
shows the children of the frame, so I wasn't sure if 2-5 were actually
doing anything at this point, or if they were just to assign references.
Ok, now my main question: I want to create a program that will allow the
user to open new tabs using the Notebook widget. I understand how to use
XRC to design a static layout, but I don't understand where the GUI code
is supposed to go for the notebook pages that will be created during the
run of the program. It's not something that I want to appear when the
program starts, so it seems like it's wrong to put them as children of
the frame. I thought maybe, since notebook pages are custom Panels, that
I could put a top-level Panel widget in the XRC file, but I tried this
and it didn't seem to work. I wasn't sure how to access it, and when the
program finally ran without errors, it just showed a frame with a panel.
So I hope someone can explain how to use XRC when you expect to create
new widgets during runtime.
Thanks!
More information about the wxpython-users
mailing list