[pygtk] How do I set radio buttons from a program
John Dennis
jdennis at redhat.com
Thu Apr 12 22:44:58 WST 2007
On Thu, 2007-04-12 at 10:29 +1000, Peter Robinson wrote:
> I am writing a simple applet whose button3 menu contains a list of radio
> buttons.
> When the applet starts up I want to be able to run a test and base the
> radio button settings on the result of the test.
> I have spend many hours looking at tutorials, manuals and google'ing for
> an answer to my problem without any luck.
>
> Any suggestions?
button.set_active(True)
Note, this will cause the 'toggled' signal to be emitted for both the
button being unset and the the button being set. You should have a
toggled signal handler shared with each button in the group, then test
for whether the button in question is active, e.g.
def radio_changed(self, radiobutton, choice):
if radiobutton.get_active():
# choice is the new button selected in the radio group
else:
# choice was unset, mostly you don't have to handle this
Note: choice is the user_data you pass in when you connect the toggled
signal to the button.
--
John Dennis <jdennis at redhat.com>
Learn. Network. Experience open source.
Red Hat Summit San Diego | May 9-11, 2007
Learn more: http://www.redhat.com/promo/summit/2007
More information about the pygtk
mailing list