radioBox

Hello all.
  I'm trying to modify the contects of a radiobox dynamically. I can't find
a method to do this. I've tried to do a .Close() then .Create(); a
.Destroy() then both .Create() or just re-instantializing. I;ve also tried
self.rb.choices.Append('new choice')

  Can someone point me in the right direction please?

-Dave

S. D. Rose wrote:

Hello all.
  I'm trying to modify the contects of a radiobox dynamically. I can't find a method to do this. I've tried to do a .Close() then .Create(); a .Destroy() then both .Create() or just re-instantializing.

Doesn't that work? When you recreate the control, don't forget to put it into the sizer (if you are using one) and then calling Layout.

I;ve also tried self.rb.choices.Append('new choice')

The list of choices is not referenced again after the radiobox is constructed, it makes a copy of the strings you give to it.

  Can someone point me in the right direction please?

wx.RadioBox is designed to be fairly static once it has been created, other than things like changing item labels. If you need to have a radio box that changes a lot I think I would try using a collection of wx.RadioButtons and manage layout with a wx.StaticBoxSizer.

···

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

Robin. Thank you for getting back to me with help. I create the radiobox like this:

···

----- Original Message ----- From: "Robin Dunn" <robin@alldunn.com>
Newsgroups: gmane.comp.python.wxpython
Sent: Thursday, May 04, 2006 8:00 PM
Subject: Re: radioBox

S. D. Rose wrote:

Hello all.
  I'm trying to modify the contects of a radiobox dynamically. I can't find a method to do this. I've tried to do a .Close() then .Create(); a .Destroy() then both .Create() or just re-instantializing.

Doesn't that work? When you recreate the control, don't forget to put it into the sizer (if you are using one) and then calling Layout.

I;ve also tried self.rb.choices.Append('new choice')

The list of choices is not referenced again after the radiobox is constructed, it makes a copy of the strings you give to it.

  Can someone point me in the right direction please?

wx.RadioBox is designed to be fairly static once it has been created, other than things like changing item labels. If you need to have a radio box that changes a lot I think I would try using a collection of wx.RadioButtons and manage layout with a wx.StaticBoxSizer.

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

Robin, thank you for replying to me with help. I use wxGlade to mostly
create the UI for me, and I'm adding the controls. First, in the dialog, I
made a panel onto which I can manually add the radiobox.

self.add_radioBox_here = wx.Panel(self, -1)
sizer_24.Add(self.add_radioBox_here, 1, wx.EXPAND, 0)

I then created the radiobox as follows:
        self.rb = wx.RadioBox(
                self.add_radioBox_here, -1,
self.cameraSelection_choice.GetStringSelection(), wx.DefaultPosition,
wx.DefaultSize,
                self.radioBoxChoice, 1, wx.RA_SPECIFY_COLS
                )

        print len(self.radioBoxChoice)
        self.rb.SetSelection( (len(self.radioBoxChoice)-1) )
        self.Refresh()

When I issue a:
         self.rb.Close()

nothing happens.

When I issue a:
        self.rb.Destroy()

I receive the following errors:

"Robin Dunn" <robin@alldunn.com> wrote in message
news:445A958A.3080403@alldunn.com...

···

S. D. Rose wrote:

Hello all.
  I'm trying to modify the contects of a radiobox dynamically. I can't
find a method to do this. I've tried to do a .Close() then .Create(); a
.Destroy() then both .Create() or just re-instantializing.

Doesn't that work? When you recreate the control, don't forget to put it
into the sizer (if you are using one) and then calling Layout.

I;ve also tried self.rb.choices.Append('new choice')

The list of choices is not referenced again after the radiobox is
constructed, it makes a copy of the strings you give to it.

  Can someone point me in the right direction please?

wx.RadioBox is designed to be fairly static once it has been created,
other than things like changing item labels. If you need to have a radio
box that changes a lot I think I would try using a collection of
wx.RadioButtons and manage layout with a wx.StaticBoxSizer.

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

I'm sorry! The error message I get is:

File "C:\Documents and
Settings\sdr\Desktop\eclipse\workspace\CheckCashing\SelectDepositSlipBundleToPrint_Dialog.py",
line 66, in OnPickDate
self.DeleteRadioBox()

File "C:\Documents and
Settings\sdr\Desktop\eclipse\workspace\CheckCashing\SelectDepositSlipBundleToPrint_Dialog.py",
line 39, in DeleteRadioBox
self.rb.Destroy()

File "C:\Python24\Lib\site-packages\wx-2.6-msw-ansi\wx\_core.py", line
13212, in __getattr__
raise PyDeadObjectError(self.attrStr % self._name)
wx._core.PyDeadObjectError: The C++ part of the RadioBox object has been
deleted, attribute access no longer allowed.

And I'm not sure why or what I can do. Thank you for your suggestions!

-Dave

"Robin Dunn" <robin@alldunn.com> wrote in message
news:445A958A.3080403@alldunn.com...

···

S. D. Rose wrote:

Hello all.
  I'm trying to modify the contects of a radiobox dynamically. I can't
find a method to do this. I've tried to do a .Close() then .Create(); a
.Destroy() then both .Create() or just re-instantializing.

Doesn't that work? When you recreate the control, don't forget to put it
into the sizer (if you are using one) and then calling Layout.

I;ve also tried self.rb.choices.Append('new choice')

The list of choices is not referenced again after the radiobox is
constructed, it makes a copy of the strings you give to it.

  Can someone point me in the right direction please?

wx.RadioBox is designed to be fairly static once it has been created,
other than things like changing item labels. If you need to have a radio
box that changes a lot I think I would try using a collection of
wx.RadioButtons and manage layout with a wx.StaticBoxSizer.

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

S. D. Rose wrote:

I'm sorry! The error message I get is:

File "C:\Documents and Settings\sdr\Desktop\eclipse\workspace\CheckCashing\SelectDepositSlipBundleToPrint_Dialog.py", line 66, in OnPickDate
self.DeleteRadioBox()

File "C:\Documents and Settings\sdr\Desktop\eclipse\workspace\CheckCashing\SelectDepositSlipBundleToPrint_Dialog.py", line 39, in DeleteRadioBox
self.rb.Destroy()

File "C:\Python24\Lib\site-packages\wx-2.6-msw-ansi\wx\_core.py", line 13212, in __getattr__
raise PyDeadObjectError(self.attrStr % self._name)
wx._core.PyDeadObjectError: The C++ part of the RadioBox object has been deleted, attribute access no longer allowed.

And I'm not sure why or what I can do. Thank you for your suggestions!

My guess is that self.DeleteRadoBox is getting called twice.

···

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