Sv: Re: Run-time modification of wxRadioBox

Hi Robin,

Thanks for answer. A straight forward solution.

My next question concerns creating a RadioBox with no options. A
simple program I made to test this is:

···

--------------
import wx

class MyFrame(wx.Frame):
    def __init__(self, *args, **kwds):
        # begin wxGlade: AlarmMonitorFrame.__init__
        kwds["style"] = wx.CAPTION|wx.CLOSE_BOX|wx.MINIMIZE_BOX|wx.
MAXIMIZE_BOX|wx.SYSTEM_MENU|wx.RESIZE_BORDER|wx.CLIP_CHILDREN
        wx.Frame.__init__(self, *args, **kwds)
        
        self.myradio = wx.RadioBox(self, -1, "My Radio", choices=[])
        
if __name__ == "__main__":
    app = wx.PySimpleApp()
    frame = MyFrame(None, -1, "")
    frame.Show()
    app.MainLoop()
--------------

The program above crashes while I seem to get the expected result if I
change the line:
< self.myradio = wx.RadioBox(self, -1, "My Radio", choices=[])
to

self.myradio = wx.RadioBox(self, -1, "My Radio", choices=[""])

Is this a bug? It seems very unintuitive and I stumbled over this
solution by mistake. Haven't been able to find anything about this on
the web or in Documentation before.

Thanks again,

Jens

----Ursprungligt meddelande----
Från: robin@alldunn.com
Datum: 14-08-2008 21:42
Till: "Jens Rantil"<jens.rantil@telia.com>, <wxpython-users@lists.
wxwidgets.org>
Ärende: Re: [wxpython-users] Run-time modification of wxRadioBox

Jens Rantil wrote:

Hi,

Is it possible to add/remove choices in a wxRadioBox at run time?

No you'll need to recreate the radiobox (and Destroy() the old one.)
To
make this appear to be a smooth process at runtime you can do
something
like this pseudocode:

1. freeze the parent
2. create new radiobox
3. insert into sizer at the same position as the old radiobox
4. destroy the old radiobox
5. call parent.Layout()
6. thaw the parent

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