Reputation: 413
I have 3 wxpython radio buttons. When run, the first button (Value A) is already selected. How do I make it so no buttons are selected initially?
self.rb1 = wx.RadioButton(panel, -1, 'Value A', (50, 10), style=wx.RB_GROUP)
self.rb2 = wx.RadioButton(panel, -1, 'Value B', (10, 30))
self.rb3 = wx.RadioButton(panel, -1, 'Value C', (10, 50))
self.Bind(wx.EVT_RADIOBUTTON, self.SetVal, id=self.rb1.GetId())
self.Bind(wx.EVT_RADIOBUTTON, self.SetVal, id=self.rb2.GetId())
self.Bind(wx.EVT_RADIOBUTTON, self.SetVal, id=self.rb3.GetId())
Upvotes: 1
Views: 548
Reputation: 9110
Using RB_GROUP
it makes buttons mutually exclusive and the first button is always checked. So if you check one this will uncheck the other. If you don't need this mutually exclusive buttons then you can use RB_SINGLE
for each of your buttons. See here the docs.
HINT
Maybe a workaround would perhaps be to create a hidden radio-button, which would be selected on creation of the group.
Upvotes: 2