/usr/share/doc/python-gtk2-tutorial/html/sec-CheckButtons.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 | <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>6.3. Check Buttons</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-ButtonWidget.html" title="Chapter 6. The Button Widget"><link rel="previous" href="sec-ToggleButtons.html" title="6.2. Toggle Buttons"><link rel="next" href="sec-RadioButtons.html" title="6.4. Radio Buttons"></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">6.3. Check Buttons</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="sec-ToggleButtons.html">Prev</a> </td><th width="60%" align="center">Chapter 6. The Button Widget</th><td width="20%" align="right"> <a accesskey="n" href="sec-RadioButtons.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-CheckButtons"></a>6.3. Check Buttons</h2></div></div><div></div></div><p>Check buttons inherit many properties and methods from the the
toggle buttons above, but look a little different. Rather than being buttons
with text inside them, they are small squares with the text to the right of
them. These are often used for toggling options on and off in
applications.</p><p>The creation method is similar to that of the normal
button.</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
check_button = gtk.CheckButton(<b class="parameter"><tt>label</tt></b>=None)
</pre></td></tr></table><p>If the <i class="parameter"><tt>label</tt></i> argument is specified the method
creates a check button with a label beside it. The <i class="parameter"><tt>label</tt></i>
text is parsed for '_'-prefixed mnemonic characters.</p><p>Checking and setting the state of the check button are
identical to that of the toggle button.</p><p>The <a href="examples/checkbutton.py" target="_top"><span><b class="command">checkbutton.py</b></span></a>
program provides an example of the use of the check buttons.
<a href="sec-CheckButtons.html#checkbuttonfig" title="Figure 6.3. Check Button Example">Figure 6.3, “Check Button Example”</a> illustrates the resulting window:</p><div class="figure"><a name="checkbuttonfig"></a><p class="title"><b>Figure 6.3. Check Button Example</b></p><div class="mediaobject" align="center"><img src="figures/checkbutton.png" align="middle" alt="Check Button Example"></div></div><p>The source code for the <a href="examples/checkbutton.py" target="_top"><span><b class="command">checkbutton.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 checkbutton.py
4
5 import pygtk
6 pygtk.require('2.0')
7 import gtk
8
9 class CheckButton:
10 # Our callback.
11 # The data passed to this method is printed to stdout
12 def callback(self, widget, data=None):
13 print "%s was toggled %s" % (data, ("OFF", "ON")[widget.get_active()])
14
15 # This callback quits the program
16 def delete_event(self, widget, event, data=None):
17 gtk.main_quit()
18 return False
19
20 def __init__(self):
21 # Create a new window
22 self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
23
24 # Set the window title
25 self.window.set_title("Check Button")
26
27 # Set a handler for delete_event that immediately
28 # exits GTK.
29 self.window.connect("delete_event", self.delete_event)
30
31 # Sets the border width of the window.
32 self.window.set_border_width(20)
33
34 # Create a vertical box
35 vbox = gtk.VBox(True, 2)
36
37 # Put the vbox in the main window
38 self.window.add(vbox)
39
40 # Create first button
41 button = gtk.CheckButton("check button 1")
42
43 # When the button is toggled, we call the "callback" method
44 # with a pointer to "button" as its argument
45 button.connect("toggled", self.callback, "check button 1")
46
47
48 # Insert button 1
49 vbox.pack_start(button, True, True, 2)
50
51 button.show()
52
53 # Create second button
54
55 button = gtk.CheckButton("check button 2")
56
57 # When the button is toggled, we call the "callback" method
58 # with a pointer to "button 2" as its argument
59 button.connect("toggled", self.callback, "check button 2")
60 # Insert button 2
61 vbox.pack_start(button, True, True, 2)
62
63 button.show()
64
65 # Create "Quit" button
66 button = gtk.Button("Quit")
67
68 # When the button is clicked, we call the mainquit function
69 # and the program exits
70 button.connect("clicked", lambda wid: gtk.main_quit())
71
72 # Insert the quit button
73 vbox.pack_start(button, True, True, 2)
74
75 button.show()
76 vbox.show()
77 self.window.show()
78
79 def main():
80 gtk.main()
81 return 0
82
83 if __name__ == "__main__":
84 CheckButton()
85 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-ToggleButtons.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch-ButtonWidget.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sec-RadioButtons.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">6.2. Toggle Buttons </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 6.4. Radio Buttons</td></tr></table></div></body></html>
|