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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
|
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>gtk.Button</title><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="index.html" title="PyGTK 2.0 Reference Manual"><link rel="up" href="gtk-class-reference.html" title="The gtk Class Reference"><link rel="previous" href="class-gtkbox.html" title="gtk.Box"><link rel="next" href="class-gtkbuttonbox.html" title="gtk.ButtonBox"></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">gtk.Button</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="class-gtkbox.html">Prev</a></td><th width="60%" align="center">The gtk Class Reference</th><td width="20%" align="right"><a accesskey="n" href="class-gtkbuttonbox.html">Next</a></td></tr></table><hr></div><div class="refentry" lang="en"><a name="class-gtkbutton"></a><div class="titlepage"><div></div><div></div></div><div class="refnamediv"><h2>gtk.Button</h2><p>gtk.Button — A pushbutton widget that issues a signal when
clicked.</p></div><div class="refsect1" lang="en"><a name="id3038837"></a><h2>Synopsis</h2><table bgcolor="#D0E0F0" width="100%"><tr><td><pre class="classsynopsis">class <span class="ooclass"><span class="classname">gtk.Button</span></span>(<span class="ooclass"><span class="classname"><a href="class-gtkbin.html" title="gtk.Bin">gtk.Bin</a></span></span>):
<code class="constructorsynopsis"> <span class="methodname"><a href="class-gtkbutton.html#constructor-gtkbutton" title="Constructor">gtk.Button</a></span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>label</tt></b></span><span class="initializer">=None</span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>stock</tt></b></span><span class="initializer">=None</span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>use_underline</tt></b></span><span class="initializer">=TRUE</span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkbutton.html#method-gtkbutton--pressed" title="gtk.Button.pressed">pressed</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkbutton.html#method-gtkbutton--released" title="gtk.Button.released">released</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkbutton.html#method-gtkbutton--clicked" title="gtk.Button.clicked">clicked</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkbutton.html#method-gtkbutton--enter" title="gtk.Button.enter">enter</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkbutton.html#method-gtkbutton--leave" title="gtk.Button.leave">leave</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkbutton.html#method-gtkbutton--set-relief" title="gtk.Button.set_relief">set_relief</a></span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>newstyle</tt></b></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkbutton.html#method-gtkbutton--get-relief" title="gtk.Button.get_relief">get_relief</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkbutton.html#method-gtkbutton--set-label" title="gtk.Button.set_label">set_label</a></span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>label</tt></b></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkbutton.html#method-gtkbutton--get-label" title="gtk.Button.get_label">get_label</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkbutton.html#method-gtkbutton--set-use-underline" title="gtk.Button.set_use_underline">set_use_underline</a></span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>use_underline</tt></b></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkbutton.html#method-gtkbutton--get-use-underline" title="gtk.Button.get_use_underline">get_use_underline</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkbutton.html#method-gtkbutton--set-use-stock" title="gtk.Button.set_use_stock">set_use_stock</a></span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>use_stock</tt></b></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkbutton.html#method-gtkbutton--get-use-stock" title="gtk.Button.get_use_stock">get_use_stock</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkbutton.html#method-gtkbutton--set-focus-on-click" title="gtk.Button.set_focus_on_click">set_focus_on_click</a></span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>focus_on_click</tt></b></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkbutton.html#method-gtkbutton--get-focus-on-click" title="gtk.Button.get_focus_on_click">get_focus_on_click</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkbutton.html#method-gtkbutton--set-alignment" title="gtk.Button.set_alignment">set_alignment</a></span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>xalign</tt></b></span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>yalign</tt></b></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkbutton.html#method-gtkbutton--get-alignment" title="gtk.Button.get_alignment">get_alignment</a></span>(<span class="methodparam"></span>)</code><br></pre></td></tr></table></div><div class="refsect1" lang="en"><a name="id3296866"></a><h2>Ancestry</h2><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="synopsis">+-- <a href="class-gobject.html" title="gobject.GObject">gobject.GObject</a>
+-- <a href="class-gtkobject.html" title="gtk.Object">gtk.Object</a>
+-- <a href="class-gtkwidget.html" title="gtk.Widget">gtk.Widget</a>
+-- <a href="class-gtkcontainer.html" title="gtk.Container">gtk.Container</a>
+-- <a href="class-gtkbin.html" title="gtk.Bin">gtk.Bin</a>
+-- <a href="class-gtkbutton.html" title="gtk.Button">gtk.Button</a>
</pre></td></tr></table></div><div class="refsect1" lang="en"><a name="id3204778"></a><h2>Properties</h2><div class="blockquote"><table width="100%" border="0" bgcolor="#E0E0E0"><tr><td valign="top"><div class="informaltable"><table width="100%" border="0"><colgroup><col><col><col></colgroup><tbody><tr valign="top"><td valign="top">"focus-on-click"</td><td valign="top">Read/Write</td><td valign="top">If <tt class="literal">TRUE</tt> the button grabs focus when
it is clicked with the mouse. This property is available in GTK+
2.4 and above.</td></tr><tr valign="top"><td valign="top">"label"</td><td valign="top">Read/Write</td><td valign="top">Text of the label widget inside the button, if the button
contains a label widget.</td></tr><tr valign="top"><td valign="top">"relief"</td><td valign="top">Read/Write</td><td valign="top">The border relief style. One of:
<tt class="literal">gtk.RELIEF_NORMAL</tt>, <tt class="literal">gtk.RELIEF_HALF</tt> or
<tt class="literal">gtk.RELIEF_NONE</tt></td></tr><tr valign="top"><td valign="top">"use-underline"</td><td valign="top">Read/Write</td><td valign="top">If <tt class="literal">TRUE</tt>, an underscore in the text
indicates the next character should be underlined and used for the mnemonic
accelerator key if it is the first character so marked</td></tr><tr valign="top"><td valign="top">"use-stock"</td><td valign="top">Read/Write</td><td valign="top">If <tt class="literal">TRUE</tt>, the label text is used to pick
a stock item instead of being displayed</td></tr><tr valign="top"><td valign="top">"xalign"</td><td valign="top">Read/Write</td><td valign="top">If the
child of the button is a <a href="class-gtkmisc.html" title="gtk.Misc"><tt class="classname">gtk.Misc</tt></a> or
<a href="class-gtkalignment.html" title="gtk.Alignment"><tt class="classname">gtk.Alignment</tt></a>,
this property can be used to control it's horizontal
alignment. The value ranges from 0.0 to 1.0 representing the fraction
of freespace to the left of the widget. This property is available in GTK+ 2.4
and above.</td></tr><tr valign="top"><td valign="top">"yalign"</td><td valign="top">Read/Write</td><td valign="top">If the
child of the button is a <a href="class-gtkmisc.html" title="gtk.Misc"><tt class="classname">gtk.Misc</tt></a> or
<a href="class-gtkalignment.html" title="gtk.Alignment"><tt class="classname">gtk.Alignment</tt></a>,
this property can be used to control it's vertical
alignment. The value ranges from 0.0 to 1.0 representing the fraction
of freespace above the widget. This property is available in GTK+ 2.4
and above.</td></tr></tbody></table></div></td></tr></table></div></div><div class="refsect1" lang="en"><a name="id3262316"></a><h2>Style Properties</h2><div class="blockquote"><table width="100%" border="0" bgcolor="#E0E0E0"><tr><td valign="top"><div class="informaltable"><table width="100%" border="0"><colgroup><col><col><col></colgroup><tbody><tr valign="top"><td valign="top">"child-displacement-y"</td><td valign="top">Read/Write</td><td valign="top">The number of pixels in the y direction to move the child
when the button is depressed</td></tr><tr valign="top"><td valign="top">"child-displacement-x"</td><td valign="top">Read/Write</td><td valign="top">The number of pixels in the x direction to move the child
when the button is depressed</td></tr><tr valign="top"><td valign="top">"default-border"</td><td valign="top">Read/Write</td><td valign="top">The extra space to add for
<tt class="literal">gtk.CAN_DEFAULT</tt> buttons</td></tr><tr valign="top"><td valign="top">"default-outside-border"</td><td valign="top">Read/Write</td><td valign="top">The extra space to add for
<tt class="literal">gtk.CAN_DEFAULT</tt> buttons always drawn outside the
border</td></tr></tbody></table></div></td></tr></table></div></div><div class="refsect1" lang="en"><a name="id3308686"></a><h2>Signal Prototypes</h2><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term">"<a href="class-gtkbutton.html#signal-gtkbutton--activate" title='The "activate" gtk.Button Signal'>activate</a>"</span></td><td><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><i class="parameter"><tt>button</tt></i></span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>user_param1</tt></i></span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>...</tt></i></span></span>)</code></td></tr><tr><td><span class="term">"<a href="class-gtkbutton.html#signal-gtkbutton--clicked" title='The "clicked" gtk.Button Signal'>clicked</a>"</span></td><td><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><i class="parameter"><tt>button</tt></i></span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>user_param1</tt></i></span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>...</tt></i></span></span>)</code></td></tr><tr><td><span class="term">"<a href="class-gtkbutton.html#signal-gtkbutton--enter" title='The "enter" gtk.Button Signal'>enter</a>"</span></td><td><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><i class="parameter"><tt>button</tt></i></span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>user_param1</tt></i></span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>...</tt></i></span></span>)</code></td></tr><tr><td><span class="term">"<a href="class-gtkbutton.html#signal-gtkbutton--leave" title='The "leave" gtk.Button Signal'>leave</a>"</span></td><td><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><i class="parameter"><tt>button</tt></i></span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>user_param1</tt></i></span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>...</tt></i></span></span>)</code></td></tr><tr><td><span class="term">"<a href="class-gtkbutton.html#signal-gtkbutton--pressed" title='The "pressed" gtk.Button Signal'>pressed</a>"</span></td><td><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><i class="parameter"><tt>button</tt></i></span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>user_param1</tt></i></span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>...</tt></i></span></span>)</code></td></tr><tr><td><span class="term">"<a href="class-gtkbutton.html#signal-gtkbutton--released" title='The "released" gtk.Button Signal'>released</a>"</span></td><td><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><i class="parameter"><tt>button</tt></i></span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>user_param1</tt></i></span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>...</tt></i></span></span>)</code></td></tr></tbody></table></div><div class="refsect1" lang="en"><a name="id3197759"></a><h2>Description</h2><p>The <a href="class-gtkbutton.html" title="gtk.Button"><tt class="classname">gtk.Button</tt></a> widget is
usually displayed as a pushbutton with a text label (<a href="class-gtklabel.html" title="gtk.Label"><tt class="classname">gtk.Label</tt></a>) though it
can contain any valid widget. The <a href="class-gtkbutton.html" title="gtk.Button"><tt class="classname">gtk.Button</tt></a> is
generally used to attach a callback function or method that is called when
the button is clicked. Buttons generate signals that indicate:</p><div class="itemizedlist"><ul type="disc"><li>"clicked" - the user pressed and released a mouse button
over the button</li><li>"pressed" - the user pressed a mouse button over the
button</li><li>"released" - the user released a mouse button over the
button</li><li>"enter" - the pointer entered the button</li><li>"leave" - the pointer left the button</li></ul></div><p>The "clicked" signal is usually the only signal that an
application needs to handle.</p><p>If a label is being used by the button its text (the "label"
property) is retrieved using the <a href="class-gtkbutton.html#method-gtkbutton--get-label" title="gtk.Button.get_label"><tt class="methodname">get_label</tt>()</a>
method. The label text is changed using the <a href="class-gtkbutton.html#method-gtkbutton--set-label" title="gtk.Button.set_label"><tt class="methodname">set_label</tt>()</a>
method.</p><p>The property ("use_underline") that tells a button to use the
first underscore to indicate a mnemonic key is changed using the <a href="class-gtkbutton.html#method-gtkbutton--set-use-underline" title="gtk.Button.set_use_underline"><tt class="methodname">set_use_underline</tt>().</a>
method. It can be retrieved using the <a href="class-gtkbutton.html#method-gtkbutton--get-use-underline" title="gtk.Button.get_use_underline"><tt class="methodname">get_use_underline</tt>()</a>
method.</p><p>The button's relief style (the "relief" property) is retrieved
using the method <a href="class-gtkbutton.html#method-gtkbutton--get-relief" title="gtk.Button.get_relief"><tt class="methodname">get_relief</tt>()</a>.
The relief style is set to one of <tt class="literal">gtk.RELIEF_NONE</tt>,
<tt class="literal">gtk.RELIEF_HALF</tt> or <tt class="literal">gtk.RELIEF_NORMAL</tt>
using the method <a href="class-gtkbutton.html#method-gtkbutton--set-relief" title="gtk.Button.set_relief"><tt class="methodname">set_relief</tt>()</a>.</p></div><div class="refsect1" lang="en"><a name="constructor-gtkbutton"></a><h2>Constructor</h2><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="constructorsynopsis"> <span class="methodname">gtk.Button</span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>label</tt></b></span><span class="initializer">=None</span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>stock</tt></b></span><span class="initializer">=None</span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>use_underline</tt></b></span><span class="initializer">=TRUE</span></span>)</code></pre></td></tr></table><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term"><b class="parameter"><tt>label</tt></b>:</span></td><td>the text to be displayed by the button label
including an underscore to indicate the mnemonic character if desired or
<tt class="literal">None</tt> if no label is required.</td></tr><tr><td><span class="term"><b class="parameter"><tt>stock</tt></b>:</span></td><td>the stock id identifying the stock image and text
to be used in the button or <tt class="literal">None</tt> if no stock id is to be
used.</td></tr><tr><td><span class="term"><b class="parameter"><tt>use_underline</tt></b>:</span></td><td>if <tt class="literal">TRUE</tt>, an underscore in the
text indicates the next character should be underlined and used for the
mnemonic accelerator key if it is the first character so
marked. Available in PyGTK 2.4 and above.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>:</span></td><td>a new button object</td></tr></tbody></table><p>Creates a new button widget with the content depending on the
parameters: <i class="parameter"><tt>label</tt></i>, <i class="parameter"><tt>stock</tt></i> and
<i class="parameter"><tt>use_underline</tt></i>. The default values for
<i class="parameter"><tt>stock</tt></i> and <i class="parameter"><tt>label</tt></i> are
<tt class="literal">None</tt> and, in PyGTK 2.4 and above,
<i class="parameter"><tt>use_underline</tt></i> is available and defaults to
<tt class="literal">TRUE</tt>. If both <i class="parameter"><tt>label</tt></i> and
<i class="parameter"><tt>stock</tt></i> are specified <i class="parameter"><tt>stock</tt></i>
takes precedence. If neither is specified the button is created with no
child widget. A child widget can be added later with the <a href="class-gtkcontainer.html#method-gtkcontainer--add" title="gtk.Container.add"><tt class="methodname">add</tt>()</a>
method.</p><p>If <i class="parameter"><tt>stock</tt></i> is specified the "use-stock"
property will be set to <tt class="literal">TRUE</tt>.</p><p>If <i class="parameter"><tt>label</tt></i> is specified the "label" property
will be set with the text of the label, the "use_underline" property will be
set to <tt class="literal">TRUE</tt> and any characters that are preceded by an
underscore are underlined (use two underscores to insert an underscore in a
label). The first underscored character will become the mnemonic character
used as the keyboard accelerator for the button when pressed simultaneously
with the <span><b class="keycap">Alt</b></span> key. In PyGTK 2.4 and above the
"use-underline" property can be set by using the optional
<i class="parameter"><tt>use_underline</tt></i> parameter.</p></div><div class="refsect1" lang="en"><a name="id3277621"></a><h2>Methods</h2><div class="refsect2" lang="en"><a name="method-gtkbutton--pressed"></a><h3>gtk.Button.pressed</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">pressed</span>(<span class="methodparam"></span>)</code></pre></td></tr></table><p>The <tt class="methodname">pressed</tt>() method emits the
"pressed" signal to the button.</p></div><div class="refsect2" lang="en"><a name="method-gtkbutton--released"></a><h3>gtk.Button.released</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">released</span>(<span class="methodparam"></span>)</code></pre></td></tr></table><p>The <tt class="methodname">released</tt>() method emits the
"released" signal to the button.</p></div><div class="refsect2" lang="en"><a name="method-gtkbutton--clicked"></a><h3>gtk.Button.clicked</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">clicked</span>(<span class="methodparam"></span>)</code></pre></td></tr></table><p>The <tt class="methodname">clicked</tt>() method emits the
"clicked" signal to the button.</p></div><div class="refsect2" lang="en"><a name="method-gtkbutton--enter"></a><h3>gtk.Button.enter</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">enter</span>(<span class="methodparam"></span>)</code></pre></td></tr></table><p>The <tt class="methodname">enter</tt>() method emits the "enter"
signal to the button.</p></div><div class="refsect2" lang="en"><a name="method-gtkbutton--leave"></a><h3>gtk.Button.leave</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">leave</span>(<span class="methodparam"></span>)</code></pre></td></tr></table><p>The <tt class="methodname">leave</tt>() method emits the "leave"
signal to the button.</p></div><div class="refsect2" lang="en"><a name="method-gtkbutton--set-relief"></a><h3>gtk.Button.set_relief</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_relief</span>(<span class="methodparam"><span class="parameter"><i class="parameter"><tt>newstyle</tt></i></span></span>)</code></pre></td></tr></table><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term"><b class="parameter"><tt>newstyle</tt></b>:</span></td><td>one of <tt class="literal">gtk.RELIEF_NONE</tt>,
<tt class="literal">gtk.RELIEF_NORMAL</tt> or
<tt class="literal">gtk.RELIEF_HALF</tt></td></tr></tbody></table><p>The <tt class="methodname">set_relief</tt>() method sets the relief
style of the edges of the button. Three styles exist,
<tt class="literal">gtk.RELIEF_NORMAL</tt>, <tt class="literal">gtk.RELIEF_HALF</tt>,
<tt class="literal">gtk.RELIEF_NONE</tt>. The default style is, as one can guess,
<tt class="literal">gtk.RELIEF_NORMAL</tt>.</p></div><div class="refsect2" lang="en"><a name="method-gtkbutton--get-relief"></a><h3>gtk.Button.get_relief</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">get_relief</span>(<span class="methodparam"></span>)</code></pre></td></tr></table><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>:</span></td><td>the relief style</td></tr></tbody></table><p>The <tt class="methodname">get_relief</tt>() method retrieves the
current relief style (the "relief" property) set for the button.</p></div><div class="refsect2" lang="en"><a name="method-gtkbutton--set-label"></a><h3>gtk.Button.set_label</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_label</span>(<span class="methodparam"><span class="parameter"><i class="parameter"><tt>label</tt></i></span></span>)</code></pre></td></tr></table><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term"><b class="parameter"><tt>label</tt></b>:</span></td><td>a string to be set as the text in the button
label</td></tr></tbody></table><p>The <tt class="methodname">set_label</tt>() method sets the text of
the button label to <i class="parameter"><tt>label</tt></i> (also sets the "label"
property). This string is also used to select the stock item if the
"use_stock" property is <tt class="literal">TRUE</tt> and the string references a
stock item. Any previously set labels will be cleared.</p></div><div class="refsect2" lang="en"><a name="method-gtkbutton--get-label"></a><h3>gtk.Button.get_label</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">get_label</span>(<span class="methodparam"></span>)</code></pre></td></tr></table><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>:</span></td><td>the text of the label
widget.</td></tr></tbody></table><p>The <tt class="methodname">get_label</tt>() method retrieves the
text from the label of the button, as set by <a href="class-gtkbutton.html#method-gtkbutton--set-label" title="gtk.Button.set_label"><tt class="methodname">set_label</tt>()</a>
or by the <a href="class-gtkbutton.html#constructor-gtkbutton" title="Constructor"><tt class="methodname">gtk.Button</tt>()</a>
constructor. This string is owned by the widget and must not be modified or
freed. If the label text has not been set the return value will be
<tt class="literal">None</tt>. This will be the case if you create an empty button
with <a href="class-gtkbutton.html#constructor-gtkbutton" title="Constructor"><tt class="methodname">gtk.Button</tt>()</a>
to use as a container.</p></div><div class="refsect2" lang="en"><a name="method-gtkbutton--set-use-underline"></a><h3>gtk.Button.set_use_underline</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_use_underline</span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>use_underline</tt></b></span></span>)</code></pre></td></tr></table><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term"><i class="parameter"><tt>use_underline</tt></i>:</span></td><td><tt class="literal">TRUE</tt> if underscores in the text
indicate mnemonics</td></tr></tbody></table><p>The <tt class="methodname">set_use_underline</tt>() method sets the
"use_underline" property to the value of
<i class="parameter"><tt>use_underline</tt></i>. If
<i class="parameter"><tt>use_underline</tt></i> is <tt class="literal">TRUE</tt>, an
underscore in the text of the button label indicates that the next character
should be underlined and used for the mnemonic accelerator key if it is also
the first underlined character.</p></div><div class="refsect2" lang="en"><a name="method-gtkbutton--get-use-underline"></a><h3>gtk.Button.get_use_underline</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">get_use_underline</span>(<span class="methodparam"></span>)</code></pre></td></tr></table><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>:</span></td><td><tt class="literal">TRUE</tt> if an underscore in the button
label indicates the mnemonic accelerator keys.</td></tr></tbody></table><p>The <tt class="methodname">get_use_underline</tt>() method returns
whether the "use_underline" property is <tt class="literal">TRUE</tt> meaning that
an underscore in the button label indicates a mnemonic. See <a href="class-gtkbutton.html#method-gtkbutton--set-use-underline" title="gtk.Button.set_use_underline"><tt class="methodname">set_use_underline</tt>()</a>.</p></div><div class="refsect2" lang="en"><a name="method-gtkbutton--set-use-stock"></a><h3>gtk.Button.set_use_stock</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_use_stock</span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>use_stock</tt></b></span></span>)</code></pre></td></tr></table><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term"><i class="parameter"><tt>use_stock</tt></i>:</span></td><td>If <tt class="literal">TRUE</tt> the button should use a
stock item</td></tr></tbody></table><p>The <tt class="methodname">set_use_stock</tt>() method sets the
"use_stock" property to the value of <i class="parameter"><tt>use_stock</tt></i>. If
<i class="parameter"><tt>use_stock</tt></i> is <tt class="literal">TRUE</tt>, the label set
on the button is used as a stock id to select the stock item for the
button.</p></div><div class="refsect2" lang="en"><a name="method-gtkbutton--get-use-stock"></a><h3>gtk.Button.get_use_stock</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">get_use_stock</span>(<span class="methodparam"></span>)</code></pre></td></tr></table><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>:</span></td><td>the value of the "use_stock" property.</td></tr></tbody></table><p>The <tt class="methodname">get_use_stock</tt>() method returns the
value of the "use_stock" property. If <tt class="literal">TRUE</tt> the button
label is used to select a stock item instead of being used directly as the
label text.</p></div><div class="refsect2" lang="en"><a name="method-gtkbutton--set-focus-on-click"></a><h3>gtk.Button.set_focus_on_click</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_focus_on_click</span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>focus_on_click</tt></b></span></span>)</code></pre></td></tr></table><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term"><i class="parameter"><tt>focus_on_click</tt></i>:</span></td><td>If <tt class="literal">TRUE</tt> the button grabs focus when
clicked with the mouse.</td></tr></tbody></table><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.4 and above.</p></div><p>The <tt class="methodname">set_focus_on_click</tt>() method sets
the "focus-on-click" property to the value of
<i class="parameter"><tt>focus_on_click</tt></i>. If
<i class="parameter"><tt>focus_on_click</tt></i> is <tt class="literal">TRUE</tt>, the button
grabs focus when it is clicked by the mouse.</p></div><div class="refsect2" lang="en"><a name="method-gtkbutton--get-focus-on-click"></a><h3>gtk.Button.get_focus_on_click</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">get_focus_on_click</span>(<span class="methodparam"></span>)</code></pre></td></tr></table><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>:</span></td><td>the value of the "focus-on-click" property.</td></tr></tbody></table><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.4 and above.</p></div><p>The <tt class="methodname">get_focus_on_click</tt>() method returns
the value of the "focus-on-click" property. If <tt class="literal">TRUE</tt> the
button grabs focus when it is clicked by the mouse .</p></div><div class="refsect2" lang="en"><a name="method-gtkbutton--set-alignment"></a><h3>gtk.Button.set_alignment</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_alignment</span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>xalign</tt></b></span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>yalign</tt></b></span></span>)</code></pre></td></tr></table><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term"><i class="parameter"><tt>xalign</tt></i>:</span></td><td>the horizontal alignment of the child widget. The value
ranges from 0.0 to 1.0 and represents the fraction of freespace
to the left of the child widget.</td></tr><tr><td><span class="term"><i class="parameter"><tt>yalign</tt></i>:</span></td><td>the vertical alignment of the child widget. The value
ranges from 0.0 to 1.0 and represents the fraction of freespace
above the child widget.</td></tr></tbody></table><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.4 and above.</p></div><p>The <tt class="methodname">set_alignment</tt>() method sets the
"xalign" and "yalign" properties to the value of
<i class="parameter"><tt>xalign</tt></i> and <i class="parameter"><tt>yalign</tt></i>
respectively. This property has no effect unless the child is a <a href="class-gtkmisc.html" title="gtk.Misc"><tt class="classname">gtk.Misc</tt></a> or a <a href="class-gtkalignment.html" title="gtk.Alignment"><tt class="classname">gtk.Alignment</tt></a>.</p></div><div class="refsect2" lang="en"><a name="method-gtkbutton--get-alignment"></a><h3>gtk.Button.get_alignment</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">get_alignment</span>(<span class="methodparam"></span>)</code></pre></td></tr></table><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>:</span></td><td>a 2-tuple containing the values of the "xalign" and
"yalign" properties.</td></tr></tbody></table><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.4 and above.</p></div><p>The <tt class="methodname">get_alignment</tt>() method returns the
values of the "xalign" and "yalign" properties. See the <a href="class-gtkbutton.html#method-gtkbutton--set-alignment" title="gtk.Button.set_alignment"><tt class="methodname">set_alignment</tt>()</a> method for more information.</p></div></div><div class="refsect1" lang="en"><a name="id3259476"></a><h2>Signals</h2><div class="refsect2" lang="en"><a name="signal-gtkbutton--activate"></a><h3>The "activate" gtk.Button Signal</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><i class="parameter"><tt>button</tt></i></span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>user_param1</tt></i></span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>...</tt></i></span></span>)</code></pre></td></tr></table><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term"><i class="parameter"><tt>button</tt></i>:</span></td><td>the button that received the "activate"
signal</td></tr><tr><td><span class="term"><i class="parameter"><tt>user_param1</tt></i>:</span></td><td>the first user parameter (if any) specified
with the <a href="class-gobject.html#method-gobject--connect" title="gobject.GObject.connect"><tt class="methodname">connect</tt>()</a>
method</td></tr><tr><td><span class="term"><i class="parameter"><tt>...</tt></i>:</span></td><td>additional user parameters (if
any)</td></tr></tbody></table><p>The "activate" signal is emitted when the <a href="class-gtkwidget.html#method-gtkwidget--activate" title="gtk.Widget.activate"><tt class="methodname">gtk.Widget.activate</tt>()</a>
method is called. For a button it causes the "clicked" signal to be
emitted.</p></div><div class="refsect2" lang="en"><a name="signal-gtkbutton--clicked"></a><h3>The "clicked" gtk.Button Signal</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><i class="parameter"><tt>button</tt></i></span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>user_param1</tt></i></span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>...</tt></i></span></span>)</code></pre></td></tr></table><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term"><i class="parameter"><tt>button</tt></i>:</span></td><td>the button that received the
signal</td></tr><tr><td><span class="term"><i class="parameter"><tt>user_param1</tt></i>:</span></td><td>the first user parameter (if any) specified
with the <a href="class-gobject.html#method-gobject--connect" title="gobject.GObject.connect"><tt class="methodname">connect</tt>()</a>
method</td></tr><tr><td><span class="term"><i class="parameter"><tt>...</tt></i>:</span></td><td>additional user parameters (if
any)</td></tr></tbody></table><p>The "clicked" signal is emitted when the mouse button is pressed
and released while the pointer is over the button.</p></div><div class="refsect2" lang="en"><a name="signal-gtkbutton--enter"></a><h3>The "enter" gtk.Button Signal</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><i class="parameter"><tt>button</tt></i></span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>user_param1</tt></i></span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>...</tt></i></span></span>)</code></pre></td></tr></table><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term"><i class="parameter"><tt>button</tt></i>:</span></td><td>the button that received the
signal</td></tr><tr><td><span class="term"><i class="parameter"><tt>user_param1</tt></i>:</span></td><td>the first user parameter (if any) specified
with the <a href="class-gobject.html#method-gobject--connect" title="gobject.GObject.connect"><tt class="methodname">connect</tt>()</a>
method</td></tr><tr><td><span class="term"><i class="parameter"><tt>...</tt></i>:</span></td><td>additional user parameters (if
any)</td></tr></tbody></table><p>The "enter" signal is emitted when the pointer enters the
button.</p></div><div class="refsect2" lang="en"><a name="signal-gtkbutton--leave"></a><h3>The "leave" gtk.Button Signal</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><i class="parameter"><tt>button</tt></i></span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>user_param1</tt></i></span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>...</tt></i></span></span>)</code></pre></td></tr></table><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term"><i class="parameter"><tt>button</tt></i>:</span></td><td>the button that received the
signal</td></tr><tr><td><span class="term"><i class="parameter"><tt>user_param1</tt></i>:</span></td><td>the first user parameter (if any) specified
with the <a href="class-gobject.html#method-gobject--connect" title="gobject.GObject.connect"><tt class="methodname">connect</tt>()</a>
method</td></tr><tr><td><span class="term"><i class="parameter"><tt>...</tt></i>:</span></td><td>additional user parameters (if
any)</td></tr></tbody></table><p>The "leave" signal is emitted when the pointer leaves the
button.</p></div><div class="refsect2" lang="en"><a name="signal-gtkbutton--pressed"></a><h3>The "pressed" gtk.Button Signal</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><i class="parameter"><tt>button</tt></i></span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>user_param1</tt></i></span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>...</tt></i></span></span>)</code></pre></td></tr></table><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term"><i class="parameter"><tt>button</tt></i>:</span></td><td>the button that received the
signal</td></tr><tr><td><span class="term"><i class="parameter"><tt>user_param1</tt></i>:</span></td><td>the first user parameter (if any) specified
with the <a href="class-gobject.html#method-gobject--connect" title="gobject.GObject.connect"><tt class="methodname">connect</tt>()</a>
method</td></tr><tr><td><span class="term"><i class="parameter"><tt>...</tt></i>:</span></td><td>additional user parameters (if
any)</td></tr></tbody></table><p>The "pressed" signal is emitted when the mouse button is pressed
while the pointer is over the button.</p></div><div class="refsect2" lang="en"><a name="signal-gtkbutton--released"></a><h3>The "released" gtk.Button Signal</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><i class="parameter"><tt>button</tt></i></span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>user_param1</tt></i></span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>...</tt></i></span></span>)</code></pre></td></tr></table><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term"><i class="parameter"><tt>button</tt></i>:</span></td><td>the button that received the
signal</td></tr><tr><td><span class="term"><i class="parameter"><tt>user_param1</tt></i>:</span></td><td>the first user parameter (if any) specified
with the <a href="class-gobject.html#method-gobject--connect" title="gobject.GObject.connect"><tt class="methodname">connect</tt>()</a>
method</td></tr><tr><td><span class="term"><i class="parameter"><tt>...</tt></i>:</span></td><td>additional user parameters (if
any)</td></tr></tbody></table><p>The "released" signal is emitted when the button is released no
matter where the pointer is.</p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="class-gtkbox.html">Prev</a></td><td width="20%" align="center"><a accesskey="u" href="gtk-class-reference.html">Up</a></td><td width="40%" align="right"><a accesskey="n" href="class-gtkbuttonbox.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">gtk.Box</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">gtk.ButtonBox</td></tr></table></div></body></html>
|