Possible Duplicate:
How to remove initial wx.RadioBox selection?
I’m working on an application that asks the user a series of questions with answers for each in a radiobox. The next question does not appear until you have answered the current one because it may depend on your answer.
My problem is that each question that shows up automatically has the first answer selected by default. I would like to have it start with nothing selected.
How can I achieve this?
Here’s the code I’m currently using for one of the questions:
import wx
hardBackOptions = ['Paperback','Hardback'];
class OptionsPanel1(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
mainpanel = wx.Panel(self)
self.cover1 = wx.RadioBox(self, label="Hardback or Paperback?", pos=(20, 140), choices=hardBackOptions, majorDimension=1, style=wx.RA_SPECIFY_COLS )
app = wx.App(False)
frame = wx.Frame(None, title="Book Pricing & Options", size=(1000,900))
nb = wx.Notebook(frame)
nb.AddPage(OptionsPanel1(nb), "Book Options")
frame.Show()
app.MainLoop()
EDIT: For what it’s worth, I ended up using wxChoice instead. Having a blank option in front of the dropdown works better for what I was trying to accomplish than having a blank option for a radio button. Here’s the change I made for anyone interested:
import wx
hardBackOptions = ['','Paperback','Hardback'];
class OptionsPanel1(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
mainpanel = wx.Panel(self)
self.coverLabel = wx.StaticText(self, label="Paperback or Hardback?", pos=(20,115))
self.cover = wx.Choice(self, pos=(20, 140), choices=hardBackOptions)
app = wx.App(False)
frame = wx.Frame(None, title="Book Pricing & Options", size=(1000,900))
nb = wx.Notebook(frame)
nb.AddPage(OptionsPanel1(nb), "Book Options")
frame.Show()
app.MainLoop()
I don’t think that you’re supposed to do that. Radio button sets should always have one value selected. I would just add a default value that’s set such as one labeled “None”.