[wxPython] Passing Arrays of Controls

This is probably a silly question but here goes.

I'm designing some screens which will be similar in appearance and contain
the same underlying code regarding multiple sizers to hold panels etc.
However the main grid sizer on the panels will have different numbers of rows
dependant on program context, , and each row may or may not have multiple
controls.

Is it possible to have a routine like:

Class BasicPanel(wxPanel):
    etc

   code in here for sizer configuration
   including grid sizers, background etc..

and pass down to that routine an array of sizers which I have 'preloaded'
with the necessary controls pertaining to a particular screen display?

Probably sounds confusing, but I'd appreciate any thoughts

DR R Terry
gnuMed Project.

I think it *should* be possible. I wrote a short script to test the idea
of dynamically (re)assigning sizers to a window, but it crashes out (on
both wxGTK and wxMSW2K) when you call the SetSizer() method on the panel
for a second time. The script it attached. If anyone can explain why it
doesn't work, I'd appreciate it.

According to the wxWindows documentation, passing a NULL argument to the
SetSizer() method should disassociate the current sizer from a window.
Is this implemented in wxPython, Robin?

cheers,

Bryan

dynamicsizer.py (970 Bytes)

···

On Wed, 2002-06-12 at 13:20, richard terry wrote:

This is probably a silly question but here goes.

I'm designing some screens which will be similar in appearance and contain
the same underlying code regarding multiple sizers to hold panels etc.
However the main grid sizer on the panels will have different numbers of rows
dependant on program context, , and each row may or may not have multiple
controls.

Is it possible to have a routine like:

Class BasicPanel(wxPanel):
    etc

   code in here for sizer configuration
   including grid sizers, background etc..

and pass down to that routine an array of sizers which I have 'preloaded'
with the necessary controls pertaining to a particular screen display?

Probably sounds confusing, but I'd appreciate any thoughts

DR R Terry
gnuMed Project.

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users

--
Bryan Cole
Teraview Ltd., 302-304 Cambridge Science Park, Milton Road, Cambridge
CB4 0WG, United Kingdom.
tel: +44 (1223) 435380 / 435386 (direct-dial) fax: +44 (1223) 435382

Is it possible to have a routine like:

Class BasicPanel(wxPanel):
    etc

   code in here for sizer configuration
   including grid sizers, background etc..

and pass down to that routine an array of sizers which I have 'preloaded'
with the necessary controls pertaining to a particular screen display?

Probably sounds confusing,

Yes <wink>

It is doable, but you'll want to ensure that the controls are children of
the panel that they appear on.

···

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

I think it *should* be possible. I wrote a short script to test the idea
of dynamically (re)assigning sizers to a window, but it crashes out (on
both wxGTK and wxMSW2K) when you call the SetSizer() method on the panel
for a second time. The script it attached. If anyone can explain why it
doesn't work, I'd appreciate it.

When you call SetSizer the old one (if any) is deleted so the crash happenss
when you try to access a deleted C++ object. In 2.3.3 there is a new 2nd
parameter to SetSizer that specifies if the old one should be deleted or
not.

According to the wxWindows documentation, passing a NULL argument to the
SetSizer() method should disassociate the current sizer from a window.
Is this implemented in wxPython, Robin?

It should be automatic. I'll see if I can figure out why it isn't working.

···

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

Thanks Robin! All makes sense now.

Bryan

···

On Wed, 2002-06-12 at 22:36, Robin Dunn wrote:

> I think it *should* be possible. I wrote a short script to test the idea
> of dynamically (re)assigning sizers to a window, but it crashes out (on
> both wxGTK and wxMSW2K) when you call the SetSizer() method on the panel
> for a second time. The script it attached. If anyone can explain why it
> doesn't work, I'd appreciate it.

When you call SetSizer the old one (if any) is deleted so the crash happenss
when you try to access a deleted C++ object. In 2.3.3 there is a new 2nd
parameter to SetSizer that specifies if the old one should be deleted or
not.

> According to the wxWindows documentation, passing a NULL argument to the
> SetSizer() method should disassociate the current sizer from a window.
> Is this implemented in wxPython, Robin?

It should be automatic. I'll see if I can figure out why it isn't working.

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

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users

--
Bryan Cole
Teraview Ltd., 302-304 Cambridge Science Park, Milton Road, Cambridge
CB4 0WG, United Kingdom.
tel: +44 (1223) 435380 / 435386 (direct-dial) fax: +44 (1223) 435382