/usr/share/doc/python-gtk2-tutorial/html/examples/radiobuttons.py is in python-gtk2-tutorial 2.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | #!/usr/bin/env python
# example radiobuttons.py
import pygtk
pygtk.require('2.0')
import gtk
class RadioButtons:
def callback(self, widget, data=None):
print "%s was toggled %s" % (data, ("OFF", "ON")[widget.get_active()])
def close_application(self, widget, event, data=None):
gtk.main_quit()
return False
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.connect("delete_event", self.close_application)
self.window.set_title("radio buttons")
self.window.set_border_width(0)
box1 = gtk.VBox(False, 0)
self.window.add(box1)
box1.show()
box2 = gtk.VBox(False, 10)
box2.set_border_width(10)
box1.pack_start(box2, True, True, 0)
box2.show()
button = gtk.RadioButton(None, "radio button1")
button.connect("toggled", self.callback, "radio button 1")
box2.pack_start(button, True, True, 0)
button.show()
button = gtk.RadioButton(button, "radio button2")
button.connect("toggled", self.callback, "radio button 2")
button.set_active(True)
box2.pack_start(button, True, True, 0)
button.show()
button = gtk.RadioButton(button, "radio button3")
button.connect("toggled", self.callback, "radio button 3")
box2.pack_start(button, True, True, 0)
button.show()
separator = gtk.HSeparator()
box1.pack_start(separator, False, True, 0)
separator.show()
box2 = gtk.VBox(False, 10)
box2.set_border_width(10)
box1.pack_start(box2, False, True, 0)
box2.show()
button = gtk.Button("close")
button.connect_object("clicked", self.close_application, self.window,
None)
box2.pack_start(button, True, True, 0)
button.set_flags(gtk.CAN_DEFAULT)
button.grab_default()
button.show()
self.window.show()
def main():
gtk.main()
return 0
if __name__ == "__main__":
RadioButtons()
main()
|