Dynamic content in a Panel

Hi there,

I would like to implement the following (I think it is a truly common pattern):

I have got a radiobox with some options. When I choose one of them, another panel, holding another radiobox, has to change, showing different options (depending by the choose of the first radiobox).

Any suggests to implement this? I’m a newbie in desktop application and wxWidgets/wxPython is the first framework I use.

Thanks in advance!

Domenico Nappo wrote:

Hi there,

I would like to implement the following (I think it is a truly common pattern):

I have got a radiobox with some options. When I choose one of them, another panel, holding another radiobox, has to change, showing different options (depending by the choose of the first radiobox).

Any suggests to implement this? I'm a newbie in desktop application and wxWidgets/wxPython is the first framework I use.

Thanks in advance!

I'm sure there are several good ways to do this. Here's a couple I came up with off the top of my head...

When you click a radio button, just create the widgets, put them in a sizer and call something like self.Layout() or self.Refresh() to make the new stuff show up correctly. Alternatively, you could create the various panels that you plan to use (if there's not a lot of them) and just Hide() the current one and Show() the new one. The latter is probably easier to understand...

···

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

Welcome!

Basically what you can do is bind an event from the radiobuttons
to an event handler function so that when the user selects one of
the radiobuttons, that function is called. In that event handler
function you can then have code that will change the other panel
in the way you want. I'm not sure what changes you want, but
you can .Hide() or .Show() widgets, or change the values in a
wx.Choice or wx.ComboBox, or really anything.

The event that you can use for the radiobuttons is listed here
under Event Handling:
http://docs.wxwidgets.org/stable/wx_wxradiobutton.html

(This is the wxWidgets documents, and so it is written with
the C++ syntax; unfortunately it seems the wxPython online
docs don't mention the event handler)

So you'd do something like the attached sample.

Good luck,
Che

radiobutton_sample.py (1.86 KB)

···

On Wed, May 13, 2009 at 6:43 AM, Domenico Nappo <domenico.nappo@gmail.com> wrote:

Hi there,

I would like to implement the following (I think it is a truly common
pattern):

I have got a radiobox with some options. When I choose one of them, another
panel, holding another radiobox, has to change, showing different options
(depending by the choose of the first radiobox).

Any suggests to implement this? I'm a newbie in desktop application and
wxWidgets/wxPython is the first framework I use.

Thanks in advance!

Hi guys,

thanks for your replies.
Show() and Hide() methods are what I’m looking for. And thanks to Che for his sample:)

To the next time (in few hours…)

~Cheers`

···

2009/5/13 C M cmpython@gmail.com

On Wed, May 13, 2009 at 6:43 AM, Domenico Nappo > > domenico.nappo@gmail.com wrote:

Hi there,

I would like to implement the following (I think it is a truly common

pattern):

I have got a radiobox with some options. When I choose one of them, another

panel, holding another radiobox, has to change, showing different options

(depending by the choose of the first radiobox).

Any suggests to implement this? I’m a newbie in desktop application and

wxWidgets/wxPython is the first framework I use.

Thanks in advance!

Welcome!

Basically what you can do is bind an event from the radiobuttons

to an event handler function so that when the user selects one of

the radiobuttons, that function is called. In that event handler

function you can then have code that will change the other panel

in the way you want. I’m not sure what changes you want, but

you can .Hide() or .Show() widgets, or change the values in a

wx.Choice or wx.ComboBox, or really anything.

The event that you can use for the radiobuttons is listed here

under Event Handling:

http://docs.wxwidgets.org/stable/wx_wxradiobutton.html

(This is the wxWidgets documents, and so it is written with

the C++ syntax; unfortunately it seems the wxPython online

docs don’t mention the event handler)

So you’d do something like the attached sample.

Good luck,

Che


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users