Cloning controls

That would work if I knew what the controls were going to be. Perhaps I
should explain a little better.

I'm reading an xml document and extracting field information that I use to
dynamically generate a form in wxPython. One of the elements in the form
should be able to be repeated (cloned) at run time. So basically another
element exactly like the previous one is generated, but I dont know what
the previous one is going to be.

*whew* I hope that wasn't too cryptic.
So basically theres a wxControl, but I dont know what type. I want another
one exactly like it, is there any way I can clone it?

thanks
Stephen Emslie

···

On Tue, 9 Sep 2003, Donnal Walter wrote:

Make your panel into its own class:

class MyPanel(wx.Panel):
    def __init__(self, *args, **kwargs):
        wx.Panel.__init__(self, *args, **kwargs)
        # code to build the panel here

Then you can make as many instances of MyPanel as you wish,
whenever you wish.

Regards,

=====
Donnal Walter
Arkansas Children's Hospital

Yes, I see. Writing code that will build a class at runtime is more
difficult, I admit, but I still think that is your best bet. I
don't know what the code looks like that generates the form in
wxPython as you wread the XML document, but I my guess is that you
could modify it to build a class instead of building an instance.
Just a thought.

Interesting problem. Regards,

···

--- stephen r emslie <semslie@cs.uct.ac.za> wrote:

That would work if I knew what the controls were going to be.
Perhaps I should explain a little better.

I'm reading an xml document and extracting field information
that I use to dynamically generate a form in wxPython. One of
the elements in the form should be able to be repeated (cloned)
at run time. So basically another element exactly like the
previous one is generated, but I dont know what the previous
one is going to be.

=====
Donnal Walter
Arkansas Children's Hospital

stephen r emslie wrote:

That would work if I knew what the controls were going to be. Perhaps I
should explain a little better.

I'm reading an xml document and extracting field information that I use to
dynamically generate a form in wxPython. One of the elements in the form
should be able to be repeated (cloned) at run time. So basically another
element exactly like the previous one is generated, but I dont know what
the previous one is going to be.

But you created the elements the first time, right? What's wrong with just doing the same dynamic construction code again?

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!