File: class-gtkaccellabel.html

package info (click to toggle)
python-gtk2-doc 2.5.2-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 8,304 kB
  • ctags: 3,741
  • sloc: makefile: 38
file content (73 lines) | stat: -rw-r--r-- 15,647 bytes parent folder | download
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
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>gtk.AccelLabel</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-gtkaccelgroup.html" title="gtk.AccelGroup"><link rel="next" href="class-gtkaccessible.html" title="gtk.Accessible"></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.AccelLabel</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="class-gtkaccelgroup.html">Prev</a></td><th width="60%" align="center">The gtk Class Reference</th><td width="20%" align="right"><a accesskey="n" href="class-gtkaccessible.html">Next</a></td></tr></table><hr></div><div class="refentry" lang="en"><a name="class-gtkaccellabel"></a><div class="titlepage"><div></div><div></div></div><div class="refnamediv"><h2>gtk.AccelLabel</h2><p>gtk.AccelLabel &#8212; a label which displays accelerator info to the right of the text</p></div><div class="refsect1" lang="en"><a name="id3212176"></a><h2>Synopsis</h2><table bgcolor="#D0E0F0" width="100%"><tr><td><pre class="classsynopsis">class <span class="ooclass"><span class="classname">gtk.AccelLabel</span></span>(<span class="ooclass"><span class="classname"><a href="class-gtklabel.html" title="gtk.Label">gtk.Label</a></span></span>):
<code class="constructorsynopsis">    <span class="methodname"><a href="class-gtkaccellabel.html#constructor-gtkaccellabel" title="Constructor">gtk.AccelLabel</a></span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>string</tt></b></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a href="class-gtkaccellabel.html#method-gtkaccellabel--accelerator-width" title="gtk.AccelLabel.accelerator_width">accelerator_width</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a href="class-gtkaccellabel.html#method-gtkaccellabel--get-accel-widget" title="gtk.AccelLabel.get_accel_widget">get_accel_widget</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a href="class-gtkaccellabel.html#method-gtkaccellabel--get-accel-width" title="gtk.AccelLabel.get_accel_width">get_accel_width</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a href="class-gtkaccellabel.html#method-gtkaccellabel--set-accel-widget" title="gtk.AccelLabel.set_accel_widget">set_accel_widget</a></span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>accel_widget</tt></b></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a href="class-gtkaccellabel.html#method-gtkaccellabel--refetch" title="gtk.AccelLabel.refetch">refetch</a></span>(<span class="methodparam"></span>)</code><br></pre></td></tr></table></div><div class="refsect1" lang="en"><a name="id3124240"></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-gtkmisc.html" title="gtk.Misc">gtk.Misc</a>
        +-- <a href="class-gtklabel.html" title="gtk.Label">gtk.Label</a>
          +-- <a href="class-gtkaccellabel.html" title="gtk.AccelLabel">gtk.AccelLabel</a>
</pre></td></tr></table></div><div class="refsect1" lang="en"><a name="id3188586"></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">"accel-closure"</td><td valign="top">Read-Write</td><td valign="top">The closure to be monitored for accelerator
changes</td></tr><tr valign="top"><td valign="top">"accel-widget"</td><td valign="top">Read-Write</td><td valign="top">The widget associated with the accelerator
label</td></tr></tbody></table></div></td></tr></table></div></div><div class="refsect1" lang="en"><a name="id3024142"></a><h2>Description</h2><p>The <a href="class-gtkaccellabel.html" title="gtk.AccelLabel"><tt class="classname">gtk.AccelLabel</tt></a>
widget is a subclass of <a href="class-gtklabel.html" title="gtk.Label"><tt class="classname">gtk.Label</tt></a> that
displays an accelerator string to the right of the label text, e.g.
<span><b class="keycap">Ctrl</b></span>+<span><b class="keycap">S</b></span>. It is commonly used in menus to show the keyboard
shortcuts for commands. The accelerator string to display is not set
explicitly; instead, the <a href="class-gtkaccellabel.html" title="gtk.AccelLabel"><tt class="classname">gtk.AccelLabel</tt></a>
displays the accelerators which have been added to the associated widget. A
widget is associated with the accelerator label by calling <a href="class-gtkaccellabel.html#method-gtkaccellabel--set-accel-widget" title="gtk.AccelLabel.set_accel_widget"><tt class="methodname">set_accel_widget</tt>()</a>.</p><p>For example, a <a href="class-gtkmenuitem.html" title="gtk.MenuItem"><tt class="classname">gtk.MenuItem</tt></a>
widget may have an accelerator added to emit the "activate" signal when the
<span><b class="keycap">Ctrl</b></span>+<span><b class="keycap">S</b></span> key combination is pressed. A <a href="class-gtkaccellabel.html" title="gtk.AccelLabel"><tt class="classname">gtk.AccelLabel</tt></a>
is created and added to the <a href="class-gtkmenuitem.html" title="gtk.MenuItem"><tt class="classname">gtk.MenuItem</tt></a>, and
<a href="class-gtkaccellabel.html#method-gtkaccellabel--set-accel-widget" title="gtk.AccelLabel.set_accel_widget"><tt class="methodname">set_accel_widget</tt>()</a> is called with the <a href="class-gtkmenuitem.html" title="gtk.MenuItem"><tt class="classname">gtk.MenuItem</tt></a> as
the first argument. The <a href="class-gtkaccellabel.html" title="gtk.AccelLabel"><tt class="classname">gtk.AccelLabel</tt></a>
will now display <span><b class="keycap">Ctrl</b></span>+<span><b class="keycap">S</b></span> after its label.</p><p>Creating a <a href="class-gtkmenuitem.html" title="gtk.MenuItem"><tt class="classname">gtk.MenuItem</tt></a> with
the <a href="class-gtkmenuitem.html#constructor-gtkmenuitem" title="Constructor"><tt class="function">gtk.MenuItem</tt>()</a>
function (or one of the similar functions <a href="class-gtkcheckmenuitem.html#constructor-gtkcheckmenuitem" title="Constructor"><tt class="function">gtk.CheckMenuItem</tt>()</a> 
and <a href="class-gtkradiomenuitem.html#constructor-gtkradiomenuitem" title="Constructor"><tt class="function">gtk.RadioMenuItem</tt>()</a>) 
and specifying a label, automatically adds a <a href="class-gtkaccellabel.html" title="gtk.AccelLabel"><tt class="classname">gtk.AccelLabel</tt></a>
to the <a href="class-gtkmenuitem.html" title="gtk.MenuItem"><tt class="classname">gtk.MenuItem</tt></a> and
calls <a href="class-gtkaccellabel.html#method-gtkaccellabel--set-accel-widget" title="gtk.AccelLabel.set_accel_widget"><tt class="methodname">set_accel_widget</tt>()</a> 
to set it up for you.</p><p>A <a href="class-gtkaccellabel.html" title="gtk.AccelLabel"><tt class="classname">gtk.AccelLabel</tt></a>
will only display accelerators which have
<tt class="literal">gtk.ACCEL_VISIBLE</tt> set. A <a href="class-gtkaccellabel.html" title="gtk.AccelLabel"><tt class="classname">gtk.AccelLabel</tt></a>
can display multiple accelerators and even signal names, though it is almost
always used to display just one accelerator.</p><p>The following code fragment creates a simple menu item with an
accelerator and enables the display of the accelerator key string in the
menu item label:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
    # Create an accelgroup and add it to the window
    accel_group = gtk.AccelGroup()
    window.add_accel_group(accel_group)

    # Create the menu item
    save_item = gtk.MenuItem("Save")
    save_item.show()
    menu.add(save_item)

    # Now add the accelerator to the menu item. Note that since we created
    # the menu item with a label the AccelLabel is automatically setup to 
    # display the accelerators.
    save_item.add_accelerator("activate", accel_group, ord("S"),
                              gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
</pre></td></tr></table><p></p></div><div class="refsect1" lang="en"><a name="constructor-gtkaccellabel"></a><h2>Constructor</h2><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="constructorsynopsis">    <span class="methodname">gtk.AccelLabel</span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>string</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"><b class="parameter"><tt>string</tt></b>:</span></td><td>the label string</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>:</span></td><td>a new <tt class="classname">gtk.AccelLabel</tt>
object</td></tr></tbody></table><p><tt class="function">gtk.AccelLabel</tt>() creates a new <a href="class-gtkaccellabel.html" title="gtk.AccelLabel"><tt class="classname">gtk.AccelLabel</tt></a>
object. The <i class="parameter"><tt>string</tt></i> parameter specifies the text to be
displayed by the label. The accelerator text is automatically added by the
associated widget.</p></div><div class="refsect1" lang="en"><a name="id3092688"></a><h2>Methods</h2><div class="refsect2" lang="en"><a name="method-gtkaccellabel--accelerator-width"></a><h3>gtk.AccelLabel.accelerator_width</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">accelerator_width</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 width in pixels needed</td></tr></tbody></table><p>The <tt class="methodname">accelerator_width</tt>() method returns
the width in pixels needed to display the accelerator(s). It is used by
menus to align all of the <a href="class-gtkmenuitem.html" title="gtk.MenuItem"><tt class="classname">gtk.MenuItem</tt></a>
widgets, and isn't usually needed by applications.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p><tt class="methodname">accelerator_width</tt>() is deprecated
- use the <a href="class-gtkaccellabel.html#method-gtkaccellabel--get-accel-width" title="gtk.AccelLabel.get_accel_width"><tt class="methodname">get_accel_width</tt>()</a> 
method instead.</p></div></div><div class="refsect2" lang="en"><a name="method-gtkaccellabel--get-accel-widget"></a><h3>gtk.AccelLabel.get_accel_widget</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">get_accel_widget</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 widget associated with the accelerator
label, or <tt class="literal">None</tt>.</td></tr></tbody></table><p>The <tt class="methodname">get_accel_widget</tt>() method retrieves
the widget associated with this accelerator label. See <a href="class-gtkaccellabel.html#method-gtkaccellabel--set-accel-widget" title="gtk.AccelLabel.set_accel_widget"><tt class="function">gtk.AccelLabel.set_accel_widget()</tt></a>.
</p></div><div class="refsect2" lang="en"><a name="method-gtkaccellabel--get-accel-width"></a><h3>gtk.AccelLabel.get_accel_width</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">get_accel_width</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 width in pixels needed</td></tr></tbody></table><p>The <tt class="methodname">get_accel_width</tt>() method returns
the width in pixels needed to display the accelerator(s). It is used by
menus to align all of the <a href="class-gtkmenuitem.html" title="gtk.MenuItem"><tt class="classname">gtk.MenuItem</tt></a>
widgets, and isn't usually needed by applications.</p></div><div class="refsect2" lang="en"><a name="method-gtkaccellabel--set-accel-widget"></a><h3>gtk.AccelLabel.set_accel_widget</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">set_accel_widget</span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>accel_widget</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"><b class="parameter"><tt>accel_widget</tt></b>:</span></td><td>the widget to be
associated.</td></tr></tbody></table><p>The <tt class="methodname">set_accel_widget</tt>() method
associates the accelerator label with the widget specified by
<i class="parameter"><tt>accel_widget</tt></i>.</p></div><div class="refsect2" lang="en"><a name="method-gtkaccellabel--refetch"></a><h3>gtk.AccelLabel.refetch</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">refetch</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>FALSE</td></tr></tbody></table><p>The <tt class="methodname">refetch</tt>() method recreates the
accelerator label string holding the accelerator information when the
accelerator is changed. The size of the string is also recalculated.</p><p>This method is not usually needed by applications since the
accelerator label string is automatically updated whenever accelerators are
added or removed from the associated widget.</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-gtkaccelgroup.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-gtkaccessible.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">gtk.AccelGroup</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">gtk.Accessible</td></tr></table></div></body></html>