I have multiple radio boxes containing three buttons as shown below. I want to keep track of clicked radio buttons within radio boxes then do some processing. I am not sure how to index radio box and then clicked radio buttons within that radio box as there are multiple boxes. Any suggestions?class MyFrame(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, "test", wx.DefaultPosition, wx.Size(900, 600))
radio1Choices = ['F','G','P']
# rb_list has 23 records -- basically used to set the distance b/w radio boxes
for i in rb_list:
self.radio1 = wx.RadioBox(scroll1, wx.ID_ANY, wx.EmptyString, (550,i), (20,5), radio1Choices, 3, wx.RA_SPECIFY_COLS | wx.NO_BORDER)
self.radio1.SetSelection( 0 )
grid_sizer.Add( self.radio1, 0, wx.ALL, 5)
# Bind the radio box select event to a function
self.radio1.Bind( wx.EVT_RADIOBOX, self.on_selected )
def on_selected(self, event):
if self.radio1.GetStringSelection() == 'F':
print "F"
elif self.radio1.GetStringSelection() == 'G':
print "G"
else:
self.radio1.GetStringSelection() == 'P'
print "P"--A couple of possibilities:
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Gadget/Steve
--
You received this message because you are subscribed to a topic in the Google Groups "wxPython-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/wxpython-users/Sju8vsYe7cM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to wxpython-user...@googlegroups.com.
I am not very good at wxpython so a little bit more explanation about possibilities would be really helpful with some form of simple examples. Appreciate it.
A couple of possibilities:--
- Make your choices list have a structure [(method, [choices])....] then you can bind to a specific handler method for each group.
- In your handler get the originating radio group from the event and then decide what to do.
Gadget/Steve
--
You received this message because you are subscribed to a topic in the Google Groups "wxPython-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/wxpython-users/Sju8vsYe7cM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to wxpython-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
rb_list = [(self.OnRadio1, ['a', 'b', 'c']), (self.OnRadio2, ['d', 'e', 'f', 'g']), ......] for (method, choices) in rb_list: radio_item = wx.RadioBox(scroll1, wx.ID_ANY, wx.EmptyString, (-1, -1), (-1, -1), radio1Choices, wx.RA_SPECIFY_COLS|wx.NO_BORDER) radio_item.SetSelection( 0 ) grid_sizer.Add(radio_item, 0, wx.ALL, 5)
# Bind the radio box select event to a function
self.Bind(wx.EVT_RADIOBOX, method, source=radio_item)
def OnRadio1(self, evt):
""" Handler for Radio Group 1 """
:
:
def OnRadio2(self, evt):
:
def OnRadioHandler(self, evt):
""" Handler for Radio Groups """
where_from = evt.GetEventObject()
# Code based on which object & object contents caused the event.
Hmm. This is interesting, instead of giving me identity (sequential number) it gives me its unique position where I placed it in split window.
Probably "i" is not the piece of information you want, but I think you
get the idea.