/usr/share/pygtk/2.0/demos/buttonbox.py is in python-gtk2-doc 2.24.0-5.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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | #!/usr/bin/env python
'''Button Box
This demo shows various button box configurations available. It also
uses stock buttons, and use of mnemonics for navigation.'''
import pygtk
pygtk.require('2.0')
import gtk
def create_bbox(horizontal=True, title=None, spacing=0,
layout=gtk.BUTTONBOX_SPREAD):
frame = gtk.Frame(title)
if horizontal:
bbox = gtk.HButtonBox()
else:
bbox = gtk.VButtonBox()
bbox.set_border_width(5)
bbox.set_layout(layout)
bbox.set_spacing(spacing)
frame.add(bbox)
button = gtk.Button(stock='gtk-ok')
bbox.add(button)
button = gtk.Button(stock='gtk-cancel')
bbox.add(button)
button = gtk.Button(stock='gtk-help')
bbox.add(button)
return frame
class ButtonBoxDemo(gtk.Window):
def __init__(self, parent=None):
# Create the toplevel window
gtk.Window.__init__(self)
try:
self.set_screen(parent.get_screen())
except AttributeError:
self.connect('destroy', lambda *w: gtk.main_quit())
self.set_title(self.__class__.__name__)
self.set_border_width(10)
main_vbox = gtk.VBox()
self.add(main_vbox)
frame_horiz = gtk.Frame("Horizontal Button Boxes")
main_vbox.pack_start(frame_horiz, padding=10)
vbox = gtk.VBox()
vbox.set_border_width(10)
frame_horiz.add(vbox)
vbox.pack_start(create_bbox(True, "Spread", 40, gtk.BUTTONBOX_SPREAD),
padding=0)
vbox.pack_start(create_bbox(True, "Edge", 40, gtk.BUTTONBOX_EDGE),
padding=5)
vbox.pack_start(create_bbox(True, "Start", 40, gtk.BUTTONBOX_START),
padding=5)
vbox.pack_start(create_bbox(True, "End", 40, gtk.BUTTONBOX_END),
padding=5)
frame_vert = gtk.Frame("Vertical Button Boxes")
main_vbox.pack_start(frame_vert, padding=10)
hbox = gtk.HBox()
hbox.set_border_width(10)
frame_vert.add(hbox)
hbox.pack_start(create_bbox(False, "Spread", 40, gtk.BUTTONBOX_SPREAD),
padding=0)
hbox.pack_start(create_bbox(False, "Edge", 40, gtk.BUTTONBOX_EDGE),
padding=5)
hbox.pack_start(create_bbox(False, "Start", 40, gtk.BUTTONBOX_START),
padding=5)
hbox.pack_start(create_bbox(False, "End", 40, gtk.BUTTONBOX_END),
padding=5)
self.show_all()
def main():
ButtonBoxDemo()
gtk.main()
if __name__ == '__main__':
main()
|