wxPython - problem dynamically adding widgets?

D. Rush dlrush-nospam at gmail.com
Tue Oct 5 02:00:44 CEST 2004

Here is some code that uses the BoxSizer to dynamically manage controls on a
form.  The magic code might me the SetSizer() and SetAutoLayout() methods.

In any event, this might provide you with a working sample to base your
design on.


"Fazan" <dr_burrito at yahoo.com> wrote in message
news:37f621d3.0410041214.305eb3e9 at posting.google.com...
> I'm trying to create a wxPython-based application with a list of
> arbitrary widgets (in this case, progress bars).  I want my
> application to dynamically add or delete widgets from the list based
> on some user action.  I first tried using a BoxSizer, and dynamically
> instantiated the new widgets and added them to the sizer at the right
> time in my application.  This caused my app to hang every time.  Only
> widgets which I created before displaying the main frame were working,
> but subsequent widget creation caused the hanging behavior.
> I've also played around with ListCtrl (with the LC_REPORT style) and
> Grid objects to achieve the desired result with no success.  ListCtrls
> allow text and images to be added; I had hoped to implement my own
> progress bars (instead of using the Gauge class) by resizing images in
> a list.  But the support for images in ListCtrls seems quite limited;
> the image can only exist at the far left side of the list and is
> limited to some fixed size.  In order to implement a progress bar I
> would need more control over the placement and size of the image.
> Although Grids support some additional controls such as Choice and
> CheckBox, they don't even support images and using a Grid seems
> awfully heavyweight.
> The sizer approach seems pretty straightforward but I can't figure out
> why the app always locks up.  Anyone have ideas about how to solve
> this?  TIA

More information about the Python-list mailing list