Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to uncheck all radio buttons in a group? (PyGTK)

Tags:

pygtk

gtk

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.

like image 848
linkmaster03 Avatar asked Nov 21 '09 01:11

linkmaster03


People also ask

How do I uncheck all radio buttons?

If you want to uncheck all the radio buttons and checkboxes you will need to add one single line (in bold): $('#clear-all').

Can you deselect a radio button UX?

Clicking a non-selected radio button will deselect whatever other button was previously selected in the list. Radio buttons are great when used correctly — they simplify the task of selecting an option.

How do you check and uncheck a radio button?

To set a radio button to checked/unchecked, select the element and set its checked property to true or false , e.g. myRadio. checked = true . When set to true , the radio button becomes checked and all other radio buttons with the same name attribute become unchecked.


1 Answers

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()
like image 174
Isaiah Avatar answered Nov 01 '22 01:11

Isaiah