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
|
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>gtk.Menu</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-gtkliststore.html" title="gtk.ListStore"><link rel="next" href="class-gtkmenubar.html" title="gtk.MenuBar"></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.Menu</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="class-gtkliststore.html">Prev</a></td><th width="60%" align="center">The gtk Class Reference</th><td width="20%" align="right"><a accesskey="n" href="class-gtkmenubar.html">Next</a></td></tr></table><hr></div><div class="refentry" lang="en"><a name="class-gtkmenu"></a><div class="titlepage"><div></div><div></div></div><div class="refnamediv"><h2>gtk.Menu</h2><p>gtk.Menu — a drop down menu widget.</p></div><div class="refsect1" lang="en"><a name="id3461066"></a><h2>Synopsis</h2><table bgcolor="#D0E0F0" width="100%"><tr><td><pre class="classsynopsis">class <span class="ooclass"><span class="classname">gtk.Menu</span></span>(<span class="ooclass"><span class="classname"><a href="class-gtkmenushell.html" title="gtk.MenuShell">gtk.MenuShell</a></span></span>):
<code class="constructorsynopsis"> <span class="methodname"><a href="class-gtkmenu.html#constructor-gtkmenu" title="Constructor">gtk.Menu</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkmenu.html#method-gtkmenu--popup" title="gtk.Menu.popup">popup</a></span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>parent_menu_shell</tt></b></span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>parent_menu_item</tt></b></span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>func</tt></b></span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>button</tt></b></span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>activate_time</tt></b></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkmenu.html#method-gtkmenu--reposition" title="gtk.Menu.reposition">reposition</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkmenu.html#method-gtkmenu--popdown" title="gtk.Menu.popdown">popdown</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkmenu.html#method-gtkmenu--get-active" title="gtk.Menu.get_active">get_active</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkmenu.html#method-gtkmenu--set-active" title="gtk.Menu.set_active">set_active</a></span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>index</tt></b></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkmenu.html#method-gtkmenu--set-accel-group" title="gtk.Menu.set_accel_group">set_accel_group</a></span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>accel_group</tt></b></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkmenu.html#method-gtkmenu--get-accel-group" title="gtk.Menu.get_accel_group">get_accel_group</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkmenu.html#method-gtkmenu--set-accel-path" title="gtk.Menu.set_accel_path">set_accel_path</a></span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>accel_path</tt></b></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkmenu.html#method-gtkmenu--attach-to-widget" title="gtk.Menu.attach_to_widget">attach_to_widget</a></span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>attach_widget</tt></b></span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>detach_func</tt></b></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkmenu.html#method-gtkmenu--detach" title="gtk.Menu.detach">detach</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkmenu.html#method-gtkmenu--get-attach-widget" title="gtk.Menu.get_attach_widget">get_attach_widget</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkmenu.html#method-gtkmenu--set-tearoff-state" title="gtk.Menu.set_tearoff_state">set_tearoff_state</a></span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>torn_off</tt></b></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkmenu.html#method-gtkmenu--get-tearoff-state" title="gtk.Menu.get_tearoff_state">get_tearoff_state</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkmenu.html#method-gtkmenu--set-title" title="gtk.Menu.set_title">set_title</a></span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>title</tt></b></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkmenu.html#method-gtkmenu--get-title" title="gtk.Menu.get_title">get_title</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkmenu.html#method-gtkmenu--reorder-child" title="gtk.Menu.reorder_child">reorder_child</a></span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>child</tt></b></span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>position</tt></b></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkmenu.html#method-gtkmenu--set-screen" title="gtk.Menu.set_screen">set_screen</a></span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>screen</tt></b></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkmenu.html#method-gtkmenu--attach" title="gtk.Menu.attach">attach</a></span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>child</tt></b></span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>left_attach</tt></b></span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>right_attach</tt></b></span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>top_attach</tt></b></span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>bottom_attach</tt></b></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gtkmenu.html#method-gtkmenu--set-monitor" title="gtk.Menu.set_monitor">set_monitor</a></span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>monitor_num</tt></b></span></span>)</code><br></pre></td></tr></table></div><div class="refsect1" lang="en"><a name="id3461469"></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-gtkmenushell.html" title="gtk.MenuShell">gtk.MenuShell</a>
+-- <a href="class-gtkmenu.html" title="gtk.Menu">gtk.Menu</a>
</pre></td></tr></table></div><div class="refsect1" lang="en"><a name="id3461510"></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">"tearoff-state"</td><td valign="top">Read-Write</td><td valign="top">If <tt class="literal">TRUE</tt> the menu is torn-off. Default
value: <tt class="literal">FALSE</tt>. Available in GTK+ 2.6 and above.</td></tr><tr valign="top"><td valign="top">"tearoff-title"</td><td valign="top">Read-Write</td><td valign="top">A title that may be displayed by the window manager
when this menu is torn-off. Default value: "".</td></tr></tbody></table></div></td></tr></table></div></div><div class="refsect1" lang="en"><a name="id3461593"></a><h2>Child Properties</h2><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>These properties are available in GTK+ 2.4 and above.</p></div><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">"bottom-attach"</td><td valign="top">Read-Write</td><td valign="top">The row number to attach the bottom of the child
to. Allowed values: >= -1. Default value: -1.</td></tr><tr valign="top"><td valign="top">"left-attach"</td><td valign="top">Read-Write</td><td valign="top">The column number to attach the left side of the child
to. Allowed values: >= -1. Default value: -1.</td></tr><tr valign="top"><td valign="top">"right-attach"</td><td valign="top">Read-Write</td><td valign="top">The column number to attach the right side of the child
to. Allowed values: >= -1. Default value: -1.</td></tr><tr valign="top"><td valign="top">"top-attach"</td><td valign="top">Read-Write</td><td valign="top">The row number to attach the top of the child to. Allowed
values: >= -1. Default value: -1.</td></tr></tbody></table></div></td></tr></table></div></div><div class="refsect1" lang="en"><a name="id3461713"></a><h2>Style Properties</h2><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>These properties are available in GTK+ 2.4 and above.</p></div><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">"horizontal-offset"</td><td valign="top">Read</td><td valign="top">When the menu is a submenu, position it this number of pixels offset horizontally. Default value: -2.</td></tr><tr valign="top"><td valign="top">"vertical-offset"</td><td valign="top">Read</td><td valign="top">When the menu is a submenu, position it this number of pixels offset vertically. Default value: 0.</td></tr><tr valign="top"><td valign="top">"vertical-padding"</td><td valign="top">Read</td><td valign="top">Extra space at the top and bottom of the menu. Allowed
values: >= 0. Default value: 1.</td></tr></tbody></table></div></td></tr></table></div></div><div class="refsect1" lang="en"><a name="id3461816"></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-gtkmenu.html#signal-gtkmenu--move-scroll" title='The "move_scroll" gtk.Menu Signal'>move-scroll</a>"</span></td><td><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><i class="parameter"><tt>menu</tt></i></span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>type</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="id3461864"></a><h2>Description</h2><p>A <a href="class-gtkmenu.html" title="gtk.Menu"><tt class="classname">gtk.Menu</tt></a> is a <a href="class-gtkmenushell.html" title="gtk.MenuShell"><tt class="classname">gtk.MenuShell</tt></a>
that implements a drop down menu consisting of a list of <a href="class-gtkmenuitem.html" title="gtk.MenuItem"><tt class="classname">gtk.MenuItem</tt></a>
objects which can be navigated and activated by the user to perform
application functions. A <a href="class-gtkmenu.html" title="gtk.Menu"><tt class="classname">gtk.Menu</tt></a> is most
commonly dropped down by activating a <a href="class-gtkmenuitem.html" title="gtk.MenuItem"><tt class="classname">gtk.MenuItem</tt></a> in a
<a href="class-gtkmenubar.html" title="gtk.MenuBar"><tt class="classname">gtk.MenuBar</tt></a>
or popped up by activating a <a href="class-gtkmenuitem.html" title="gtk.MenuItem"><tt class="classname">gtk.MenuItem</tt></a> in
another <a href="class-gtkmenu.html" title="gtk.Menu"><tt class="classname">gtk.Menu</tt></a>. A <a href="class-gtkmenu.html" title="gtk.Menu"><tt class="classname">gtk.Menu</tt></a> can also be
popped up by activating a <a href="class-gtkoptionmenu.html" title="gtk.OptionMenu"><tt class="classname">gtk.OptionMenu</tt></a>.
Other composite widgets such as the <a href="class-gtknotebook.html" title="gtk.Notebook"><tt class="classname">gtk.Notebook</tt></a> can
pop up a <a href="class-gtkmenu.html" title="gtk.Menu"><tt class="classname">gtk.Menu</tt></a> as well.
Applications can display a <a href="class-gtkmenu.html" title="gtk.Menu"><tt class="classname">gtk.Menu</tt></a> as a popup
menu by calling the <a href="class-gtkmenu.html#method-gtkmenu--popup" title="gtk.Menu.popup"><tt class="methodname">popup</tt>()</a>
method.</p></div><div class="refsect1" lang="en"><a name="constructor-gtkmenu"></a><h2>Constructor</h2><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="constructorsynopsis"> <span class="methodname">gtk.Menu</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 <a href="class-gtkmenu.html" title="gtk.Menu"><tt class="classname">gtk.Menu</tt></a>
widget</td></tr></tbody></table><p>Creates a new <a href="class-gtkmenu.html" title="gtk.Menu"><tt class="classname">gtk.Menu</tt></a>
widget.</p></div><div class="refsect1" lang="en"><a name="id3462018"></a><h2>Methods</h2><div class="refsect2" lang="en"><a name="method-gtkmenu--popup"></a><h3>gtk.Menu.popup</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">popup</span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>parent_menu_shell</tt></b></span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>parent_menu_item</tt></b></span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>func</tt></b></span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>button</tt></b></span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>activate_time</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>parent_menu_shell</tt></b>:</span></td><td>the menu shell containing the triggering menu
item or <tt class="literal">None</tt>.</td></tr><tr><td><span class="term"><b class="parameter"><tt>parent_menu_item</tt></b>:</span></td><td>the menu item whose activation triggered the
popup or <tt class="literal">None</tt>.</td></tr><tr><td><span class="term"><b class="parameter"><tt>func</tt></b>:</span></td><td>a user supplied function used to position the
menu or <tt class="literal">None</tt>.</td></tr><tr><td><span class="term"><b class="parameter"><tt>button</tt></b>:</span></td><td>the mouse button which was pressed to initiate
the event. </td></tr><tr><td><span class="term"><b class="parameter"><tt>activate_time</tt></b>:</span></td><td>the time at which the activation event
occurred.</td></tr></tbody></table><p>The <tt class="methodname">popup</tt>() method displays a menu and
makes it available for selection. Applications can use this function to
display context-sensitive menus, and will typically supply
<tt class="literal">None</tt> for the <i class="parameter"><tt>parent_menu_shell</tt></i>,
<i class="parameter"><tt>parent_menu_item</tt></i> and <i class="parameter"><tt>func</tt></i>
parameters. The default menu positioning function will position the menu at
the current pointer position. The <i class="parameter"><tt>button</tt></i> and
<i class="parameter"><tt>activate_time</tt></i> values should be the mouse button that
was pressed to trigger the menu popup and the time the button was pressed.
These values can usually be retrieved from the "button_press_event".</p></div><div class="refsect2" lang="en"><a name="method-gtkmenu--reposition"></a><h3>gtk.Menu.reposition</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">reposition</span>(<span class="methodparam"></span>)</code></pre></td></tr></table><p>The <tt class="methodname">reposition</tt>() method repositions the
menu on the screen according to the internal position function.</p></div><div class="refsect2" lang="en"><a name="method-gtkmenu--popdown"></a><h3>gtk.Menu.popdown</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">popdown</span>(<span class="methodparam"></span>)</code></pre></td></tr></table><p>The <tt class="methodname">popdown</tt>() method removes the menu
from the screen.</p></div><div class="refsect2" lang="en"><a name="method-gtkmenu--get-active"></a><h3>gtk.Menu.get_active</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">get_active</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 <a href="class-gtkmenuitem.html" title="gtk.MenuItem"><tt class="classname">gtk.MenuItem</tt></a> that
was last selected in the menu. If a selection has not yet been made, the
first menu item is selected.</td></tr></tbody></table><p>The <tt class="methodname">get_active</tt>() method returns the
selected menu item from the menu. This is used by the <a href="class-gtkoptionmenu.html" title="gtk.OptionMenu"><tt class="classname">gtk.OptionMenu</tt></a>.</p></div><div class="refsect2" lang="en"><a name="method-gtkmenu--set-active"></a><h3>gtk.Menu.set_active</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_active</span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>index</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>index</tt></b>:</span></td><td>the index of the menu item to select. Index
values start from 0.</td></tr></tbody></table><p>The <tt class="methodname">set_active</tt>() method selects the
menu item within the menu at the location specified by
<i class="parameter"><tt>index</tt></i>. This is used by the <a href="class-gtkoptionmenu.html" title="gtk.OptionMenu"><tt class="classname">gtk.OptionMenu</tt></a>
and is not useful for applications.</p></div><div class="refsect2" lang="en"><a name="method-gtkmenu--set-accel-group"></a><h3>gtk.Menu.set_accel_group</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_accel_group</span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>accel_group</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_group</tt></b>:</span></td><td>a <a href="class-gtkaccelgroup.html" title="gtk.AccelGroup"><tt class="classname">gtk.AccelGroup</tt></a></td></tr></tbody></table><p>The <tt class="methodname">set_accel_group</tt>() method associates
the <a href="class-gtkaccelgroup.html" title="gtk.AccelGroup"><tt class="classname">gtk.AccelGroup</tt></a>
specified by <i class="parameter"><tt>accel_group</tt></i> with the menu. The
accelerator group should also be added to all windows using this menu by
calling the <a href="class-gtkwindow.html#method-gtkwindow--add-accel-group" title="gtk.Window.add_accel_group"><tt class="methodname">gtk.Window.add_accel_group</tt>()</a>
method.</p></div><div class="refsect2" lang="en"><a name="method-gtkmenu--get-accel-group"></a><h3>gtk.Menu.get_accel_group</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">get_accel_group</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 <a href="class-gtkaccelgroup.html" title="gtk.AccelGroup"><tt class="classname">gtk.AccelGroup</tt></a>
associated with the menu. </td></tr></tbody></table><p>The <tt class="methodname">get_accel_group</tt>() method returns
the <a href="class-gtkaccelgroup.html" title="gtk.AccelGroup"><tt class="classname">gtk.AccelGroup</tt></a>
that holds the global accelerators for the menu.</p></div><div class="refsect2" lang="en"><a name="method-gtkmenu--set-accel-path"></a><h3>gtk.Menu.set_accel_path</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_accel_path</span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>accel_path</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_path</tt></b>:</span></td><td>a valid accelerator path</td></tr></tbody></table><p>The <tt class="methodname">set_accel_path</tt>() method sets an
accelerator path (specified by <i class="parameter"><tt>accel_path</tt></i>) for this
menu to be used to construct accelerator paths for its menu items. This is a
convenience method used to avoid calling the <a href="class-gtkmenuitem.html#method-gtkmenuitem--set-accel-path" title="gtk.MenuItem.set_accel_path"><tt class="methodname">gtk.MenuItem.set_accel_path</tt>()</a>
method on each menu item that should support runtime user changeable
accelerators. Instead, by just calling <a href="class-gtkmenu.html#method-gtkmenu--set-accel-path" title="gtk.Menu.set_accel_path"><tt class="methodname">set_accel_path</tt>()</a>
on their parent, each menu item of this menu, that contains a label
describing its purpose, automatically gets an accel path assigned. For
example, calling:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
menu.set_accel_path("<main>/File")
</pre></td></tr></table><p>for a menu containing menu items "New" and "Exit", will assign
its items the accel paths: <tt class="literal">"<main>/File/New"</tt> and
<tt class="literal">"<main>/File/Exit"</tt>. Assigning accel paths to menu
items enables the user to change their accelerators at runtime.</p></div><div class="refsect2" lang="en"><a name="method-gtkmenu--attach-to-widget"></a><h3>gtk.Menu.attach_to_widget</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">attach_to_widget</span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>attach_widget</tt></b></span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>detach_func</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>attach_widget</tt></b>:</span></td><td>the widget that the menu will be attached
to.</td></tr><tr><td><span class="term"><b class="parameter"><tt>detach_func</tt></b>:</span></td><td>the user supplied callback function that will
be called when the menu calls the <a href="class-gtkmenu.html#method-gtkmenu--detach" title="gtk.Menu.detach"><tt class="methodname">detach</tt>()</a>
method.</td></tr></tbody></table><p>The <tt class="methodname">attach_to_widget</tt>() method attaches
the menu to the widget specified by <i class="parameter"><tt>attach_widget</tt></i> and
provides a callback function specified by <i class="parameter"><tt>detach_func</tt></i>
that will be invoked when the menu calls the <a href="class-gtkmenu.html#method-gtkmenu--detach" title="gtk.Menu.detach"><tt class="methodname">detach</tt>()</a>
method during its destruction.</p></div><div class="refsect2" lang="en"><a name="method-gtkmenu--detach"></a><h3>gtk.Menu.detach</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">detach</span>(<span class="methodparam"></span>)</code></pre></td></tr></table><p>The <tt class="methodname">detach</tt>() method detaches the menu
from the widget to which it had been attached. See <a href="class-gtkmenu.html#method-gtkmenu--attach-to-widget" title="gtk.Menu.attach_to_widget"><tt class="methodname">attach_to_widget</tt>()</a>().
</p></div><div class="refsect2" lang="en"><a name="method-gtkmenu--get-attach-widget"></a><h3>gtk.Menu.get_attach_widget</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">get_attach_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 that the menu is attached
to.</td></tr></tbody></table><p>The <tt class="methodname">get_attach_widget</tt>() method returns
the <a href="class-gtkwidget.html" title="gtk.Widget"><tt class="classname">gtk.Widget</tt></a>
that the menu is attached to.</p></div><div class="refsect2" lang="en"><a name="method-gtkmenu--set-tearoff-state"></a><h3>gtk.Menu.set_tearoff_state</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_tearoff_state</span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>torn_off</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>torn_off</tt></b>:</span></td><td>If <tt class="literal">TRUE</tt>, the menu is
displayed as a tearoff menu.</td></tr></tbody></table><p>The <tt class="methodname">set_tearoff_state</tt>() method sets the
tearoff state of the menu to the value of <i class="parameter"><tt>torn_off</tt></i>.
If <i class="parameter"><tt>torn_off</tt></i> is <tt class="literal">TRUE</tt> the menu is
displayed as a tearoff menu; if <i class="parameter"><tt>torn_off</tt></i> is
<tt class="literal">FALSE</tt> the menu is displayed as a drop down menu which
persists as long as the menu is active.</p></div><div class="refsect2" lang="en"><a name="method-gtkmenu--get-tearoff-state"></a><h3>gtk.Menu.get_tearoff_state</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">get_tearoff_state</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 the menu is
currently torn off.</td></tr></tbody></table><p>The <tt class="methodname">get_tearoff_state</tt>() method returns
whether the menu is torn off. See <a href="class-gtkmenu.html#method-gtkmenu--set-tearoff-state" title="gtk.Menu.set_tearoff_state"><tt class="methodname">set_tearoff_state</tt>()</a>.</p></div><div class="refsect2" lang="en"><a name="method-gtkmenu--set-title"></a><h3>gtk.Menu.set_title</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_title</span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>title</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>title</tt></b>:</span></td><td>a string containing the title for the
menu.</td></tr></tbody></table><p>The <tt class="methodname">set_title</tt>() method sets the title
text (from the value of <i class="parameter"><tt>title</tt></i>) to be used for the
menu when it is shown as a tearoff menu.</p></div><div class="refsect2" lang="en"><a name="method-gtkmenu--get-title"></a><h3>gtk.Menu.get_title</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">get_title</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 title of the menu, or
<tt class="literal">None</tt> if the menu has no title set on
it.</td></tr></tbody></table><p>The <tt class="methodname">get_title</tt>() method returns the
title of the menu or <tt class="literal">None</tt> of no title is set. See <a href="class-gtkmenu.html#method-gtkmenu--set-title" title="gtk.Menu.set_title"><tt class="methodname">set_title</tt>()</a>.</p></div><div class="refsect2" lang="en"><a name="method-gtkmenu--reorder-child"></a><h3>gtk.Menu.reorder_child</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">reorder_child</span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>child</tt></b></span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>position</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>child</tt></b>:</span></td><td>the <a href="class-gtkmenuitem.html" title="gtk.MenuItem"><tt class="classname">gtk.MenuItem</tt></a> to
move.</td></tr><tr><td><span class="term"><b class="parameter"><tt>position</tt></b>:</span></td><td>the new position to place child. Positions are
numbered starting from 0</td></tr></tbody></table><p>The <tt class="methodname">reorder_child</tt>() method moves the
menuitem specified by <i class="parameter"><tt>child</tt></i> to a new position within
the menu specified by <i class="parameter"><tt>position</tt></i>.</p></div><div class="refsect2" lang="en"><a name="method-gtkmenu--set-screen"></a><h3>gtk.Menu.set_screen</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_screen</span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>screen</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>screen</tt></b>:</span></td><td>a <a href="class-gdkscreen.html" title="gtk.gdk.Screen"><tt class="classname">gtk.gdk.Screen</tt></a>,
or <tt class="literal">None</tt> if the screen should be determined by
the widget the menu is attached to.</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.2 and above.</p></div><p>The <tt class="methodname">set_screen</tt>() method sets the <a href="class-gdkscreen.html" title="gtk.gdk.Screen"><tt class="classname">gtk.gdk.Screen</tt></a>
specified by <i class="parameter"><tt>screen</tt></i> on which the menu will be
displayed. If <i class="parameter"><tt>screen</tt></i> is <tt class="literal">None</tt> the
screen is determined by the widget that the menu is attached to.</p></div><div class="refsect2" lang="en"><a name="method-gtkmenu--attach"></a><h3>gtk.Menu.attach</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">attach</span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>child</tt></b></span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>left_attach</tt></b></span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>right_attach</tt></b></span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>top_attach</tt></b></span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>bottom_attach</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>child</tt></b>:</span></td><td>a <a href="class-gtkmenuitem.html" title="gtk.MenuItem"><tt class="classname">gtk.MenuItem</tt></a>.</td></tr><tr><td><span class="term"><b class="parameter"><tt>left_attach</tt></b>:</span></td><td>The column number to attach the left side of
the item to.</td></tr><tr><td><span class="term"><b class="parameter"><tt>right_attach</tt></b>:</span></td><td>The column number to attach the right side of
the item to.</td></tr><tr><td><span class="term"><b class="parameter"><tt>top_attach</tt></b>:</span></td><td>The row number to attach the top of the item
to.</td></tr><tr><td><span class="term"><b class="parameter"><tt>bottom_attach</tt></b>:</span></td><td>The row number to attach the bottom of the item
to.</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">attach</tt>() method adds a new <a href="class-gtkmenuitem.html" title="gtk.MenuItem"><tt class="classname">gtk.MenuItem</tt></a>
specified by <i class="parameter"><tt>child</tt></i> to a (table) menu. The number of
'cells' that an item will occupy is specified by
<i class="parameter"><tt>left_attach</tt></i>, <i class="parameter"><tt>right_attach</tt></i>,
<i class="parameter"><tt>top_attach</tt></i> and
<i class="parameter"><tt>bottom_attach</tt></i>. These each represent the leftmost,
rightmost, uppermost and lower column and row numbers of the table.
(Columns and rows are indexed from zero).</p><p>Note that this function is not related to the <a href="class-gtkmenu.html#method-gtkmenu--detach" title="gtk.Menu.detach"><tt class="methodname">detach()</tt></a>
method.</p></div><div class="refsect2" lang="en"><a name="method-gtkmenu--set-monitor"></a><h3>gtk.Menu.set_monitor</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_monitor</span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>monitor_num</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>monitor_num</tt></b>:</span></td><td>the number of the monitor on which the menu
should be popped up</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_monitor</tt>() method informs
<tt class="literal">GTK</tt>+ on which monitor a menu should be popped up. See
the <a href="class-gdkscreen.html#method-gdkscreen--get-monitor-geometry" title="gtk.gdk.Screen.get_monitor_geometry"><tt class="methodname">gtk.gdk.Screen.get_monitor_geometry()</tt></a>
method for more information.</p><p>This method should be called from a menu positioning function if
the menu should not appear on the same monitor as the pointer. This
information can't be reliably inferred from the coordinates returned by a
menu positioning function, since, for very long menus, these coordinates may
extend beyond the monitor boundaries or even the screen boundaries.</p></div></div><div class="refsect1" lang="en"><a name="id3463439"></a><h2>Signals</h2><div class="refsect2" lang="en"><a name="signal-gtkmenu--move-scroll"></a><h3>The "move_scroll" gtk.Menu 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>menu</tt></i></span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>type</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>menu</tt></i>:</span></td><td>the menu that received the
signal</td></tr><tr><td><span class="term"><i class="parameter"><tt>type</tt></i>:</span></td><td>the type of scroll that is requested</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><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This signal is available in GTK+ 2.2 and above.</p></div><p>The "move_scroll" signal is emitted when the user attempts to
scroll the menu. <i class="parameter"><tt>type</tt></i> should be one of the <a href="gtk-constants.html#gtk-scroll-step-constants">GTK Scroll Step Constants</a>.</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-gtkliststore.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-gtkmenubar.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">gtk.ListStore</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">gtk.MenuBar</td></tr></table></div></body></html>
|