Way to uncheck all radio buttons in a group? (PyGTK)

gtkpygtk

Is there a way to uncheck all radio buttons in a group with PyGTK? No radio buttons are checked on startup, so I think there must be a way to return them all to that unchecked state.

Best Solution

I agree with Michael, but for the record this can be done.

One way to do this would be to have a hidden radio button that you could activate, which would then cause all the visible ones to be inactive. Quick n' Dirty example:

import gtk

window = gtk.Window()
window.set_default_size(200, 200)

rb1 = gtk.RadioButton()
rb2 = gtk.RadioButton()
rb3 = gtk.RadioButton()

rb2.set_group(rb1)
rb3.set_group(rb2)

rb3.set_active(True)

hbox = gtk.HBox()

hbox.add(rb1)
hbox.add(rb2)
hbox.add(rb3)

button = gtk.Button("Click me")
button.connect("clicked", lambda x: rb3.set_active(True))

hbox.add(button)

window.add(hbox)
window.show_all()

rb3.hide()

gtk.main()
Related Question