Three RadioButtons. You can see in the terminal if they are turned off or on.
In line 16 the signal "toggled"
is connected to the callback function toggled_cb()
using widget.connect(signal, callback function)
. See for a more detailed explanation.
As seen in , instead of button1 = Gtk.RadioButton(label="Button 1")
we could create the button and label it with
button1 = Gtk.RadioButton()
button1.set_label("Button 1").
Yet another way to create a new RadioButton with a label is button1 = Gtk.RadioButton.new_with_label(None, "Button 1")
(the first argument is the group of the radiobuttons, which we can get with get_group()
, the second argument is the label).
In this sample we used the following:
GtkWindow
GtkGrid
GtkRadioButton