/usr/share/doc/python-gtk2-tutorial/html/sec-ButtonBoxes.html 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 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 127 128 129 130 131 132 133 | <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>10.10. Button Boxes</title><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="index.html" title="PyGTK 2.0 Tutorial"><link rel="up" href="ch-ContainerWidgets.html" title="Chapter 10. Container Widgets"><link rel="previous" href="sec-ScrolledWindows.html" title="10.9. Scrolled Windows"><link rel="next" href="sec-Toolbar.html" title="10.11. Toolbar"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">10.10. Button Boxes</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="sec-ScrolledWindows.html">Prev</a> </td><th width="60%" align="center">Chapter 10. Container Widgets</th><td width="20%" align="right"> <a accesskey="n" href="sec-Toolbar.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec-ButtonBoxes"></a>10.10. Button Boxes</h2></div></div><div></div></div><p><tt class="classname">ButtonBoxes</tt> are a convenient way to
quickly layout a group of buttons. They come in both horizontal and vertical
flavors. You create a new <tt class="classname">ButtonBox</tt> with one of the
following calls, which create a horizontal or vertical box,
respectively:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
hbutton_box = gtk.HButtonBox()
vbutton_box = gtk.VButtonBox()
</pre></td></tr></table><p>The only methods pertaining to button boxes effect how the
buttons are laid out.</p><p>The layout of the buttons within the box is set using:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
button_box.set_layout(<b class="parameter"><tt>layout_style</tt></b>)
</pre></td></tr></table><p>The <i class="parameter"><tt>layout_style</tt></i> argument can take one of
the following values:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
BUTTONBOX_DEFAULT_STYLE
BUTTONBOX_SPREAD
BUTTONBOX_EDGE
BUTTONBOX_START
BUTTONBOX_END
</pre></td></tr></table><p>The current <i class="parameter"><tt>layout_style</tt></i> setting can be
retrieved using:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
layout_style = button_box.get_layout()
</pre></td></tr></table><p>Buttons are added to a <tt class="classname">ButtonBox</tt> using
the usual <tt class="classname">Container</tt> method:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
button_box.add(<b class="parameter"><tt>widget</tt></b>)
</pre></td></tr></table><p>The <a href="examples/buttonbox.py" target="_top"><span><b class="command">buttonbox.py</b></span></a> example
program illustrates all the different layout settings for
<tt class="classname">ButtonBoxes</tt>.
The resulting display is:</p><div class="informalfigure"><a name="buttonboxfig"></a><div class="mediaobject" align="center"><img src="figures/buttonbox.png" align="middle"></div></div><p>The source code for the <a href="examples/buttonbox.py" target="_top"><span><b class="command">buttonbox.py</b></span></a> program
is:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
1 #!/usr/bin/env python
2
3 # example buttonbox.py
4
5 import pygtk
6 pygtk.require('2.0')
7 import gtk
8
9 class ButtonBoxExample:
10 # Create a Button Box with the specified parameters
11 def create_bbox(self, horizontal, title, spacing, layout):
12 frame = gtk.Frame(title)
13
14 if horizontal:
15 bbox = gtk.HButtonBox()
16 else:
17 bbox = gtk.VButtonBox()
18
19 bbox.set_border_width(5)
20 frame.add(bbox)
21
22 # Set the appearance of the Button Box
23 bbox.set_layout(layout)
24 bbox.set_spacing(spacing)
25
26 button = gtk.Button(stock=gtk.STOCK_OK)
27 bbox.add(button)
28
29 button = gtk.Button(stock=gtk.STOCK_CANCEL)
30 bbox.add(button)
31
32 button = gtk.Button(stock=gtk.STOCK_HELP)
33 bbox.add(button)
34
35 return frame
36
37 def __init__(self):
38 window = gtk.Window(gtk.WINDOW_TOPLEVEL)
39 window.set_title("Button Boxes")
40
41 window.connect("destroy", lambda x: gtk.main_quit())
42
43 window.set_border_width(10)
44
45 main_vbox = gtk.VBox(False, 0)
46 window.add(main_vbox)
47
48 frame_horz = gtk.Frame("Horizontal Button Boxes")
49 main_vbox.pack_start(frame_horz, True, True, 10)
50
51 vbox = gtk.VBox(False, 0)
52 vbox.set_border_width(10)
53 frame_horz.add(vbox)
54
55 vbox.pack_start(self.create_bbox(True, "Spread (spacing 40)",
56 40, gtk.BUTTONBOX_SPREAD),
57 True, True, 0)
58
59 vbox.pack_start(self.create_bbox(True, "Edge (spacing 30)",
60 30, gtk.BUTTONBOX_EDGE),
61 True, True, 5)
62
63 vbox.pack_start(self.create_bbox(True, "Start (spacing 20)",
64 20, gtk.BUTTONBOX_START),
65 True, True, 5)
66
67 vbox.pack_start(self.create_bbox(True, "End (spacing 10)",
68 10, gtk.BUTTONBOX_END),
69 True, True, 5)
70
71 frame_vert = gtk.Frame("Vertical Button Boxes")
72 main_vbox.pack_start(frame_vert, True, True, 10)
73
74 hbox = gtk.HBox(False, 0)
75 hbox.set_border_width(10)
76 frame_vert.add(hbox)
77
78 hbox.pack_start(self.create_bbox(False, "Spread (spacing 5)",
79 5, gtk.BUTTONBOX_SPREAD),
80 True, True, 0)
81
82 hbox.pack_start(self.create_bbox(False, "Edge (spacing 30)",
83 30, gtk.BUTTONBOX_EDGE),
84 True, True, 5)
85
86 hbox.pack_start(self.create_bbox(False, "Start (spacing 20)",
87 20, gtk.BUTTONBOX_START),
88 True, True, 5)
89
90 hbox.pack_start(self.create_bbox(False, "End (spacing 20)",
91 20, gtk.BUTTONBOX_END),
92 True, True, 5)
93
94 window.show_all()
95
96 def main():
97 # Enter the event loop
98 gtk.main()
99 return 0
100
101 if __name__ == "__main__":
102 ButtonBoxExample()
103 main()
</pre></td></tr></table></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sec-ScrolledWindows.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch-ContainerWidgets.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sec-Toolbar.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">10.9. Scrolled Windows </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 10.11. Toolbar</td></tr></table></div></body></html>
|