/usr/share/pygtk/2.0/demos/panes.py is in python-gtk2-doc 2.24.0-5.1ubuntu2.
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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | #!/usr/bin/env python
"""Paned Widgets
The GtkHPaned and GtkVPaned Widgets divide their content area into two panes
with a divider in between that the user can adjust. A separate child is placed
into each pane.
There are a number of options that can be set for each pane. This test contains
both a horizontal(HPaned) and a vertical(VPaned) widget, and allows you to
adjust the options for each side of each widget."""
import pygtk
pygtk.require('2.0')
import gtk
class PanedWidgetsDemo(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(0)
vbox = gtk.VBox(False, 0)
self.add(vbox)
vpaned = gtk.VPaned()
vbox.pack_start(vpaned, True, True)
vpaned.set_border_width(5)
hpaned = gtk.HPaned()
vpaned.add1(hpaned)
frame = gtk.Frame()
frame.set_shadow_type(gtk.SHADOW_IN)
frame.set_size_request(60, 60)
hpaned.add1(frame)
button = gtk.Button("_Hi there")
frame.add(button)
frame = gtk.Frame()
frame.set_shadow_type(gtk.SHADOW_IN)
frame.set_size_request(80, 60)
hpaned.add2(frame)
frame = gtk.Frame()
frame.set_shadow_type(gtk.SHADOW_IN)
frame.set_size_request(60, 80)
vpaned.add2(frame)
# Now create toggle buttons to control sizing
vbox.pack_start(
self.__create_pane_options(hpaned, "Horizontal", "Left", "Right"),
False, False, 0)
vbox.pack_start(
self.__create_pane_options(vpaned, "Vertical", "Top", "Bottom"),
False, False, 0)
self.show_all()
def on_resize_toggled(self, tbutton, child):
paned = child.parent
if child == paned.get_children()[0]:
paned.remove(child)
paned.pack1(child, tbutton.get_active(), 0)
else:
paned.remove(child)
paned.pack2(child, tbutton.get_active(), 0)
def on_shrink_toggled(self, tbutton, child):
paned = child.parent
if child == paned.get_children()[0]:
paned.remove(child)
paned.pack1(child, 0, tbutton.get_active())
else:
paned.remove(child)
paned.pack2(child, 0, tbutton.get_active())
def __create_pane_options(self, paned, frame_label, label1, label2):
frame = gtk.Frame(frame_label)
frame.set_border_width(4)
table = gtk.Table(3, 2, True)
frame.add(table)
label = gtk.Label(label1)
table.attach(label, 0, 1, 0, 1)
check_button = gtk.CheckButton("_Resize")
check_button.connect('toggled', self.on_resize_toggled, paned.get_children()[0])
table.attach(check_button, 0, 1, 1, 2)
check_button = gtk.CheckButton("_Shrink")
check_button.set_active(True)
check_button.connect('toggled', self.on_shrink_toggled, paned.get_children()[0])
table.attach(check_button, 0, 1, 2, 3)
label = gtk.Label(label2)
table.attach(label, 1, 2, 0, 1)
check_button = gtk.CheckButton("_Resize")
check_button.set_active(True)
check_button.connect('toggled', self.on_resize_toggled, paned.get_children()[1])
table.attach(check_button, 1, 2, 1, 2)
check_button = gtk.CheckButton("_Shrink")
check_button.set_active(True)
check_button.connect('toggled', self.on_shrink_toggled, paned.get_children()[1])
table.attach(check_button, 1, 2, 2, 3)
return frame
def main():
PanedWidgetsDemo()
gtk.main()
if __name__ == '__main__':
main()
|