Marjoram
Marjoram

Reputation: 413

Get Selected Button from RadioButton Group with Wxpython

I have two wxpython radio button groups:

    self.red = wx.RadioButton(panel, -1, 'Red', (10, q2y), style=wx.RB_GROUP)
    self.orange = wx.RadioButton(panel, -1, 'Orange', (50, q2y))
    self.yellow = wx.RadioButton(panel, -1, 'Yellow', (100, q2y))

    self.dot = wx.RadioButton(panel, -1, 'Dot', (10, q3y), style=wx.RB_GROUP)
    self.triangle = wx.RadioButton(panel, -1, 'Triangle', (50, q3y))
    self.rectange = wx.RadioButton(panel, -1, 'Rectangle', (100, q3y))

Is there an easy way to get the selected radio button from each group without looping through all of the buttons?

Upvotes: 0

Views: 673

Answers (1)

Werner
Werner

Reputation: 2096

Bind using wx.EVT_RADIOBUTTON and use event.GetEventObject in the event handler to get the selected button. See the wxPython demo for RadioButton for a code sample.

Upvotes: 1

Related Questions