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 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210
|
<?xml version="1.0" standalone="no"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<refentry id="class-gtkmenu">
<refnamediv>
<refname>gtk.Menu</refname>
<refpurpose>a drop down menu widget.</refpurpose>
</refnamediv>
<refsect1>
<title>Synopsis</title>
<classsynopsis language="python">
<ooclass><classname>gtk.Menu</classname></ooclass>
<ooclass><classname><link
linkend="class-gtkmenushell">gtk.MenuShell</link></classname></ooclass>
<constructorsynopsis language="python">
<methodname><link
linkend="constructor-gtkmenu">gtk.Menu</link></methodname>
<methodparam></methodparam> </constructorsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-gtkmenu--popup">popup</link></methodname>
<methodparam><parameter
role="keyword">parent_menu_shell</parameter></methodparam>
<methodparam><parameter
role="keyword">parent_menu_item</parameter></methodparam>
<methodparam><parameter
role="keyword">func</parameter></methodparam>
<methodparam><parameter
role="keyword">button</parameter></methodparam>
<methodparam><parameter
role="keyword">activate_time</parameter></methodparam>
<methodparam><parameter
role="keyword">data</parameter><initializer>None</initializer></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-gtkmenu--reposition">reposition</link></methodname>
<methodparam></methodparam> </methodsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-gtkmenu--popdown">popdown</link></methodname>
<methodparam></methodparam> </methodsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-gtkmenu--get-active">get_active</link></methodname>
<methodparam></methodparam> </methodsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-gtkmenu--set-active">set_active</link></methodname>
<methodparam><parameter
role="keyword">index</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-gtkmenu--set-accel-group">set_accel_group</link></methodname>
<methodparam><parameter
role="keyword">accel_group</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-gtkmenu--get-accel-group">get_accel_group</link></methodname>
<methodparam></methodparam> </methodsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-gtkmenu--set-accel-path">set_accel_path</link></methodname>
<methodparam><parameter
role="keyword">accel_path</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkmenu--get-accel-path">get_accel_path</link></methodname>
<methodparam></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-gtkmenu--attach-to-widget">attach_to_widget</link></methodname>
<methodparam><parameter
role="keyword">attach_widget</parameter></methodparam>
<methodparam><parameter
role="keyword">detach_func</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-gtkmenu--detach">detach</link></methodname>
<methodparam></methodparam> </methodsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-gtkmenu--get-attach-widget">get_attach_widget</link></methodname>
<methodparam></methodparam> </methodsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-gtkmenu--set-tearoff-state">set_tearoff_state</link></methodname>
<methodparam><parameter
role="keyword">torn_off</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-gtkmenu--get-tearoff-state">get_tearoff_state</link></methodname>
<methodparam></methodparam> </methodsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-gtkmenu--set-title">set_title</link></methodname>
<methodparam><parameter
role="keyword">title</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-gtkmenu--get-title">get_title</link></methodname>
<methodparam></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-gtkmenu--reorder-child">reorder_child</link></methodname>
<methodparam><parameter
role="keyword">child</parameter></methodparam>
<methodparam><parameter
role="keyword">position</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkmenu--set-screen">set_screen</link></methodname>
<methodparam><parameter
role="keyword">screen</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkmenu--attach">attach</link></methodname>
<methodparam><parameter
role="keyword">child</parameter></methodparam>
<methodparam><parameter
role="keyword">left_attach</parameter></methodparam>
<methodparam><parameter
role="keyword">right_attach</parameter></methodparam>
<methodparam><parameter
role="keyword">top_attach</parameter></methodparam>
<methodparam><parameter
role="keyword">bottom_attach</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkmenu--set-monitor">set_monitor</link></methodname>
<methodparam><parameter
role="keyword">monitor_num</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkmenu--get-monitor">get_monitor</link></methodname>
<methodparam></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkmenu--set-reserve-toggle-size">set_reserve_toggle_size</link></methodname>
<methodparam><parameter role="keyword">reserve_toggle_size</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkmenu--get-reserve-toggle-size">get_reserve_toggle_size</link></methodname>
<methodparam></methodparam>
</methodsynopsis>
</classsynopsis>
</refsect1>
<refsect1>
<title>Ancestry</title>
<synopsis>+-- <link linkend="class-gobject">gobject.GObject</link>
+-- <link linkend="class-gtkobject">gtk.Object</link>
+-- <link linkend="class-gtkwidget">gtk.Widget</link>
+-- <link linkend="class-gtkcontainer">gtk.Container</link>
+-- <link linkend="class-gtkmenushell">gtk.MenuShell</link>
+-- <link linkend="class-gtkmenu">gtk.Menu</link>
</synopsis>
</refsect1>
<refsect1>
<title>Implemented Interfaces</title>
<para>
<link linkend="class-gtkmenu"><classname>gtk.Menu</classname></link>
implements
<link linkend="class-gtkbuildable"><classname>gtk.Buildable</classname></link>
</para>
</refsect1>
<refsect1 id="properties-gtkmenu">
<title>gtk.Menu Properties</title>
<para><link linkend="properties-gtkobject">gtk.Object Properties</link></para>
<para><link linkend="properties-gtkwidget">gtk.Widget Properties</link></para>
<para><link linkend="properties-gtkcontainer">gtk.Container Properties</link></para>
<para><link linkend="properties-gtkmenushell">gtk.MenuShell Properties</link></para>
<blockquote role="properties">
<informaltable pgwide="1" frame="none">
<tgroup cols="3">
<colspec column="1" colwidth="1in"/>
<colspec column="2" colwidth="1in"/>
<colspec column="3" colwidth="4in"/>
<tbody>
<row valign="top">
<entry>"accel-group"</entry>
<entry>Read/Write</entry>
<entry>The accel group holding accelerators for the menu.
Available in GTK+ 2.14.</entry>
</row>
<row valign="top">
<entry>"accel-path"</entry>
<entry>Read/Write</entry>
<entry>An accel path used to conveniently construct accel paths of
child items. Default value: <literal>None</literal>.
Available in GTK+ 2.14.</entry>
</row>
<row valign="top">
<entry>"active"</entry>
<entry>Read/Write</entry>
<entry>The index of the currently selected menu item, or -1 if no menu
item is selected. Allowed values: >= -1. Default value: -1.
Available in GTK+ 2.14.</entry>
</row>
<row valign="top">
<entry>"attach-widget"</entry>
<entry>Read/Write</entry>
<entry>The widget the menu is attached to. Setting this property attaches
the menu without a GtkMenuDetachFunc. If you need to use a detacher,
use <methodname><link linkend="method-gtkmenu--attach-to-widget">gtk.Menu.attach_to_widget</link></methodname>()
directly.
Available in GTK+ 2.14.</entry>
</row>
<row valign="top">
<entry>"monitor"</entry>
<entry>Read/Write</entry>
<entry>The monitor the menu will be popped up on.
Allowed values: >= -1. Default value: -1.
Available in GTK+ 2.14.</entry>
</row>
<row valign="top">
<entry>"reserve-toggle-size"</entry>
<entry>Read/Write</entry>
<entry>Whether the menu reserves space for toggles and icons, regardless of their actual presence.
This property should only be changed from its default value for special-purposes such as tabular menus. Regular menus that are connected to a menu bar or context menus should reserve toggle space for consistency.
Default value: <literal>True</literal>
Available in GTK+ 2.18.</entry>
</row>
<row valign="top">
<entry>"tearoff-state"</entry>
<entry>Read-Write</entry>
<entry>If <literal>True</literal> the menu is torn-off. Default
value: <literal>False</literal>. Available in GTK+ 2.6 and above.</entry>
</row>
<row valign="top">
<entry>"tearoff-title"</entry>
<entry>Read-Write</entry>
<entry>A title that may be displayed by the window manager
when this menu is torn-off. Default value: "".</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</blockquote>
</refsect1>
<refsect1 id="style-properties-gtkmenu">
<title>gtk.Menu Style Properties</title>
<para><link linkend="style-properties-gtkwidget">gtk.Widget Style Properties</link></para>
<note>
<para>These properties are available in GTK+ 2.4 and above.</para>
</note>
<blockquote role="properties">
<informaltable pgwide="1" frame="none">
<tgroup cols="3">
<colspec column="1" colwidth="1in"/>
<colspec column="2" colwidth="1in"/>
<colspec column="3" colwidth="4in"/>
<tbody>
<row valign="top">
<entry>"arrow-placement"</entry>
<entry>Read</entry>
<entry>When the menu is a submenu, position it this number of pixels offset horizontally.
Default value: <literal>gtk.ARROWS_BOTH</literal>.</entry>
Available in GTK+ 2.16 and above.
</row>
<row valign="top">
<entry>"arrow-scaling"</entry>
<entry>Read</entry>
<entry>Arbitrary constant to scale down the size of the scroll arrow.
Allowed values: [0,1].
Default value: 0.7</entry>
</row>
<row valign="top">
<entry>"double-arrows"</entry>
<entry>Read</entry>
<entry>When scrolling, always show both arrows.
Default value: <literal>True</literal></entry>
</row>
<row valign="top">
<entry>"horizontal-offset"</entry>
<entry>Read</entry>
<entry>When the menu is a submenu, position it this number of pixels offset horizontally. Default value: -2.</entry>
</row>
<row valign="top">
<entry>"horizontal-padding"</entry>
<entry>Read</entry>
<entry>Extra space at the left and right edges of the menu</entry>
</row>
<row valign="top">
<entry>"vertical-offset"</entry>
<entry>Read</entry>
<entry>When the menu is a submenu, position it this number of pixels offset vertically. Default value: 0.</entry>
</row>
<row valign="top">
<entry>"vertical-padding"</entry>
<entry>Read</entry>
<entry>Extra space at the top and bottom of the menu. Allowed values: >= 0. Default value: 1.</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</blockquote>
</refsect1>
<refsect1 id="child-properties-gtkmenu">
<title>gtk.Menu Child Properties</title>
<note>
<para>These properties are available in GTK+ 2.4 and above.</para>
</note>
<blockquote role="properties">
<informaltable pgwide="1" frame="none">
<tgroup cols="3">
<colspec column="1" colwidth="1in"/>
<colspec column="2" colwidth="1in"/>
<colspec column="3" colwidth="4in"/>
<tbody>
<row valign="top">
<entry>"bottom-attach"</entry>
<entry>Read-Write</entry>
<entry>The row number to attach the bottom of the child
to. Allowed values: >= -1. Default value: -1.</entry>
</row>
<row valign="top">
<entry>"left-attach"</entry>
<entry>Read-Write</entry>
<entry>The column number to attach the left side of the child
to. Allowed values: >= -1. Default value: -1.</entry>
</row>
<row valign="top">
<entry>"right-attach"</entry>
<entry>Read-Write</entry>
<entry>The column number to attach the right side of the child
to. Allowed values: >= -1. Default value: -1.</entry>
</row>
<row valign="top">
<entry>"top-attach"</entry>
<entry>Read-Write</entry>
<entry>The row number to attach the top of the child to. Allowed
values: >= -1. Default value: -1.</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</blockquote>
</refsect1>
<refsect1 id="signal-prototypes-gtkmenu">
<title>gtk.Menu Signal Prototypes</title>
<para><link linkend="signal-prototypes-gobject">gobject.GObject Signal Prototypes</link></para>
<para><link linkend="signal-prototypes-gtkobject">gtk.Object Signal Prototypes</link></para>
<para><link linkend="signal-prototypes-gtkwidget">gtk.Widget Signal Prototypes</link></para>
<para><link linkend="signal-prototypes-gtkcontainer">gtk.Container Signal Prototypes</link></para>
<para><link linkend="signal-prototypes-gtkmenushell">gtk.MenuShell Signal Prototypes</link></para>
<variablelist>
<varlistentry>
<term>"<link linkend="signal-gtkmenu--move-scroll">move-scroll</link>"</term>
<listitem>
<methodsynopsis language="python"><methodname>callback</methodname>
<methodparam><parameter>menu</parameter></methodparam>
<methodparam><parameter>type</parameter></methodparam>
<methodparam><parameter>user_param1</parameter></methodparam>
<methodparam><parameter>...</parameter></methodparam>
</methodsynopsis>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>A <link
linkend="class-gtkmenu"><classname>gtk.Menu</classname></link> is a <link
linkend="class-gtkmenushell"><classname>gtk.MenuShell</classname></link>
that implements a drop down menu consisting of a list of <link
linkend="class-gtkmenuitem"><classname>gtk.MenuItem</classname></link>
objects which can be navigated and activated by the user to perform
application functions. A <link
linkend="class-gtkmenu"><classname>gtk.Menu</classname></link> is most
commonly dropped down by activating a <link
linkend="class-gtkmenuitem"><classname>gtk.MenuItem</classname></link> in a
<link linkend="class-gtkmenubar"><classname>gtk.MenuBar</classname></link>
or popped up by activating a <link
linkend="class-gtkmenuitem"><classname>gtk.MenuItem</classname></link> in
another <link
linkend="class-gtkmenu"><classname>gtk.Menu</classname></link>. A <link
linkend="class-gtkmenu"><classname>gtk.Menu</classname></link> can also be
popped up by activating a <link
linkend="class-gtkoptionmenu"><classname>gtk.OptionMenu</classname></link>.
Other composite widgets such as the <link
linkend="class-gtknotebook"><classname>gtk.Notebook</classname></link> can
pop up a <link
linkend="class-gtkmenu"><classname>gtk.Menu</classname></link> as well.
Applications can display a <link
linkend="class-gtkmenu"><classname>gtk.Menu</classname></link> as a popup
menu by calling the <link
linkend="method-gtkmenu--popup"><methodname>popup</methodname>()</link>
method.</para>
</refsect1>
<refsect1 id="constructor-gtkmenu">
<title>Constructor</title>
<programlisting><constructorsynopsis language="python">
<methodname>gtk.Menu</methodname>
<methodparam></methodparam> </constructorsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>a <link
linkend="class-gtkmenu"><classname>gtk.Menu</classname></link>
widget</simpara></listitem>
</varlistentry>
</variablelist>
<para>Creates a new <link
linkend="class-gtkmenu"><classname>gtk.Menu</classname></link>
widget.</para>
</refsect1>
<refsect1>
<title>Methods</title>
<refsect2 id="method-gtkmenu--popup">
<title>gtk.Menu.popup</title>
<programlisting><methodsynopsis language="python">
<methodname>popup</methodname>
<methodparam><parameter
role="keyword">parent_menu_shell</parameter></methodparam>
<methodparam><parameter
role="keyword">parent_menu_item</parameter></methodparam>
<methodparam><parameter
role="keyword">func</parameter></methodparam>
<methodparam><parameter
role="keyword">button</parameter></methodparam>
<methodparam><parameter
role="keyword">activate_time</parameter></methodparam>
<methodparam><parameter
role="keyword">data</parameter><initializer>None</initializer></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter
role="keyword">parent_menu_shell</parameter> :</term>
<listitem><simpara>the menu shell containing the triggering menu
item or <literal>None</literal>.</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter
role="keyword">parent_menu_item</parameter> :</term>
<listitem><simpara>the menu item whose activation triggered the
popup or <literal>None</literal>.</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter role="keyword">func</parameter> :</term>
<listitem><simpara>a user supplied function used to position the
menu or <literal>None</literal>.</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter role="keyword">button</parameter> :</term>
<listitem><simpara>the mouse button which was pressed to initiate
the event. </simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter
role="keyword">activate_time</parameter> :</term>
<listitem><simpara>the time at which the activation event
occurred.</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter
role="keyword">data</parameter> :</term>
<listitem><simpara>optional data to be passed to
<parameter>func</parameter></simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>popup</methodname>() method displays a menu and
makes it available for selection. Applications can use this function
to display context-sensitive menus, and will typically supply
<literal>None</literal> for the
<parameter>parent_menu_shell</parameter>,
<parameter>parent_menu_item</parameter> and
<parameter>func</parameter> parameters. The default menu positioning
function will position the menu at the current pointer position. The
<parameter>button</parameter> and <parameter>activate_time</parameter>
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".</para>
<para>The signature of <parameter>func</parameter> is:</para>
<programlisting>
def func(menu, user_data):
</programlisting>
<para>where <parameter>user_data</parameter> is
<parameter>data</parameter> if not
<literal>None</literal>. <parameter>func</parameter> should return a
3-tuple containing the x and y coordinates of the position to draw the
menu and a boolean that, if <literal>True</literal>, indicates that
the menu should be pushed in to be completely inside the screen
instead of just clamped to the size of the screen.</para>
<note>
<para>Prior to PyGTK 2.10 this method did not accept the
<parameter>data</parameter> parameter and the signature of
<parameter>func</parameter> was:</para>
<programlisting>
def func(menu, user_data):
</programlisting>
</note>
</refsect2>
<refsect2 id="method-gtkmenu--reposition">
<title>gtk.Menu.reposition</title>
<programlisting><methodsynopsis language="python">
<methodname>reposition</methodname>
<methodparam></methodparam> </methodsynopsis></programlisting>
<para>The <methodname>reposition</methodname>() method repositions the
menu on the screen according to the internal position function.</para>
</refsect2>
<refsect2 id="method-gtkmenu--popdown">
<title>gtk.Menu.popdown</title>
<programlisting><methodsynopsis language="python">
<methodname>popdown</methodname>
<methodparam></methodparam> </methodsynopsis></programlisting>
<para>The <methodname>popdown</methodname>() method removes the menu
from the screen.</para>
</refsect2>
<refsect2 id="method-gtkmenu--get-active">
<title>gtk.Menu.get_active</title>
<programlisting><methodsynopsis language="python">
<methodname>get_active</methodname>
<methodparam></methodparam> </methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>the <link
linkend="class-gtkmenuitem"><classname>gtk.MenuItem</classname></link> that
was last selected in the menu. If a selection has not yet been made, the
first menu item is selected.</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>get_active</methodname>() method returns the
selected menu item from the menu. This is used by the <link
linkend="class-gtkoptionmenu"><classname>gtk.OptionMenu</classname></link>.</para>
</refsect2>
<refsect2 id="method-gtkmenu--set-active">
<title>gtk.Menu.set_active</title>
<programlisting><methodsynopsis language="python">
<methodname>set_active</methodname>
<methodparam><parameter
role="keyword">index</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">index</parameter> :</term>
<listitem><simpara>the index of the menu item to select. Index
values start from 0.</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>set_active</methodname>() method selects the
menu item within the menu at the location specified by
<parameter>index</parameter>. This is used by the <link
linkend="class-gtkoptionmenu"><classname>gtk.OptionMenu</classname></link>
and is not useful for applications.</para>
</refsect2>
<refsect2 id="method-gtkmenu--set-accel-group">
<title>gtk.Menu.set_accel_group</title>
<programlisting><methodsynopsis language="python">
<methodname>set_accel_group</methodname>
<methodparam><parameter
role="keyword">accel_group</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter
role="keyword">accel_group</parameter> :</term>
<listitem><simpara>a <link
linkend="class-gtkaccelgroup"><classname>gtk.AccelGroup</classname></link></simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>set_accel_group</methodname>() method associates
the <link
linkend="class-gtkaccelgroup"><classname>gtk.AccelGroup</classname></link>
specified by <parameter>accel_group</parameter> with the menu. The
accelerator group should also be added to all windows using this menu by
calling the <link
linkend="method-gtkwindow--add-accel-group"><methodname>gtk.Window.add_accel_group</methodname>()</link>
method.</para>
</refsect2>
<refsect2 id="method-gtkmenu--get-accel-group">
<title>gtk.Menu.get_accel_group</title>
<programlisting><methodsynopsis language="python">
<methodname>get_accel_group</methodname>
<methodparam></methodparam> </methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>the <link
linkend="class-gtkaccelgroup"><classname>gtk.AccelGroup</classname></link>
associated with the menu. </simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>get_accel_group</methodname>() method returns
the <link
linkend="class-gtkaccelgroup"><classname>gtk.AccelGroup</classname></link>
that holds the global accelerators for the menu.</para>
</refsect2>
<refsect2 id="method-gtkmenu--set-accel-path">
<title>gtk.Menu.set_accel_path</title>
<programlisting><methodsynopsis language="python">
<methodname>set_accel_path</methodname>
<methodparam><parameter
role="keyword">accel_path</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter
role="keyword">accel_path</parameter> :</term>
<listitem><simpara>a valid accelerator path</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>set_accel_path</methodname>() method sets an
accelerator path (specified by <parameter>accel_path</parameter>) for this
menu to be used to construct accelerator paths for its menu items. This is a
convenience method used to avoid calling the <link
linkend="method-gtkmenuitem--set-accel-path"><methodname>gtk.MenuItem.set_accel_path</methodname>()</link>
method on each menu item that should support runtime user changeable
accelerators. Instead, by just calling <link
linkend="method-gtkmenu--set-accel-path"><methodname>set_accel_path</methodname>()</link>
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:</para>
<programlisting>
menu.set_accel_path("<main>/File")
</programlisting>
<para>for a menu containing menu items "New" and "Exit", will assign
its items the accel paths: <literal>"<main>/File/New"</literal> and
<literal>"<main>/File/Exit"</literal>. Assigning accel paths to menu
items enables the user to change their accelerators at runtime.</para>
</refsect2>
<refsect2 id="method-gtkmenu--get-accel-path">
<title>gtk.Menu.get_accel_path</title>
<programlisting><methodsynopsis language="python">
<methodname>get_accel_path</methodname>
<methodparam></methodparam> </methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>the accelerator path set on the menu.</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.14 and above.</para>
</note>
<para>
The <methodname>get_accel_path</methodname>() method returns
the accelerator path set on the menu.
</para>
</refsect2>
<refsect2 id="method-gtkmenu--attach-to-widget">
<title>gtk.Menu.attach_to_widget</title>
<programlisting><methodsynopsis language="python">
<methodname>attach_to_widget</methodname>
<methodparam><parameter
role="keyword">attach_widget</parameter></methodparam>
<methodparam><parameter
role="keyword">detach_func</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter
role="keyword">attach_widget</parameter> :</term>
<listitem><simpara>the widget that the menu will be attached
to.</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter
role="keyword">detach_func</parameter> :</term>
<listitem><simpara>the user supplied callback function that will
be called when the menu calls the <link
linkend="method-gtkmenu--detach"><methodname>detach</methodname>()</link>
method.</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>attach_to_widget</methodname>() method attaches
the menu to the widget specified by <parameter>attach_widget</parameter> and
provides a callback function specified by <parameter>detach_func</parameter>
that will be invoked when the menu calls the <link
linkend="method-gtkmenu--detach"><methodname>detach</methodname>()</link>
method during its destruction. Attaching a menu to a widget associates the
menu with a widget similar to setting a parent. This is mainly used for
associating popup menus with a widget and a submenu with a menuitem.</para>
<para>The signature of <parameter>detach</parameter> is:</para>
<programlisting>
def detach_cb(menu, widget):
</programlisting>
<para>where <parameter>menu</parameter> is the
menu being detached and <parameter>widget</parameter> is the
<parameter>attach_widget</parameter>.</para>
<note>
<para>For historical reasons, arguments for <parameter>detach</parameter>
callback are swapped compared to GTK+ C API.</para>
</note>
</refsect2>
<refsect2 id="method-gtkmenu--detach">
<title>gtk.Menu.detach</title>
<programlisting><methodsynopsis language="python">
<methodname>detach</methodname>
<methodparam></methodparam> </methodsynopsis></programlisting>
<para>The <methodname>detach</methodname>() method detaches the menu
from the widget to which it had been attached. See <link
linkend="method-gtkmenu--attach-to-widget"><methodname>attach_to_widget</methodname>()</link>.
</para>
</refsect2>
<refsect2 id="method-gtkmenu--get-attach-widget">
<title>gtk.Menu.get_attach_widget</title>
<programlisting><methodsynopsis language="python">
<methodname>get_attach_widget</methodname>
<methodparam></methodparam> </methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>the widget that the menu is attached
to.</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>get_attach_widget</methodname>() method returns
the <link linkend="class-gtkwidget"><classname>gtk.Widget</classname></link>
that the menu is attached to.</para>
</refsect2>
<refsect2 id="method-gtkmenu--set-tearoff-state">
<title>gtk.Menu.set_tearoff_state</title>
<programlisting><methodsynopsis language="python">
<methodname>set_tearoff_state</methodname>
<methodparam><parameter
role="keyword">torn_off</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">torn_off</parameter> :</term>
<listitem><simpara>If <literal>True</literal>, the menu is
displayed as a tearoff menu.</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>set_tearoff_state</methodname>() method sets the
tearoff state of the menu to the value of <parameter>torn_off</parameter>.
If <parameter>torn_off</parameter> is <literal>True</literal> the menu is
displayed as a tearoff menu; if <parameter>torn_off</parameter> is
<literal>False</literal> the menu is displayed as a drop down menu which
persists as long as the menu is active.</para>
</refsect2>
<refsect2 id="method-gtkmenu--get-tearoff-state">
<title>gtk.Menu.get_tearoff_state</title>
<programlisting><methodsynopsis language="python">
<methodname>get_tearoff_state</methodname>
<methodparam></methodparam> </methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara><literal>True</literal> if the menu is
currently torn off.</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>get_tearoff_state</methodname>() method returns
whether the menu is torn off. See <link
linkend="method-gtkmenu--set-tearoff-state"><methodname>set_tearoff_state</methodname>()</link>.</para>
</refsect2>
<refsect2 id="method-gtkmenu--set-title">
<title>gtk.Menu.set_title</title>
<programlisting><methodsynopsis language="python">
<methodname>set_title</methodname>
<methodparam><parameter
role="keyword">title</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">title</parameter> :</term>
<listitem><simpara>a string containing the title for the
menu.</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>set_title</methodname>() method sets the title
text (from the value of <parameter>title</parameter>) to be used for the
menu when it is shown as a tearoff menu.</para>
</refsect2>
<refsect2 id="method-gtkmenu--get-title">
<title>gtk.Menu.get_title</title>
<programlisting><methodsynopsis language="python">
<methodname>get_title</methodname>
<methodparam></methodparam> </methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>the title of the menu, or
<literal>None</literal> if the menu has no title set on
it.</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>get_title</methodname>() method returns the
title of the menu or <literal>None</literal> of no title is set. See <link
linkend="method-gtkmenu--set-title"><methodname>set_title</methodname>()</link>.</para>
</refsect2>
<refsect2 id="method-gtkmenu--reorder-child">
<title>gtk.Menu.reorder_child</title>
<programlisting><methodsynopsis language="python">
<methodname>reorder_child</methodname>
<methodparam><parameter
role="keyword">child</parameter></methodparam>
<methodparam><parameter
role="keyword">position</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">child</parameter> :</term>
<listitem><simpara>the <link
linkend="class-gtkmenuitem"><classname>gtk.MenuItem</classname></link> to
move.</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter role="keyword">position</parameter> :</term>
<listitem><simpara>the new position to place child. Positions are
numbered starting from 0</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>reorder_child</methodname>() method moves the
menuitem specified by <parameter>child</parameter> to a new position within
the menu specified by <parameter>position</parameter>.</para>
</refsect2>
<refsect2 id="method-gtkmenu--set-screen">
<title>gtk.Menu.set_screen</title>
<programlisting><methodsynopsis language="python">
<methodname>set_screen</methodname>
<methodparam><parameter role="keyword">screen</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">screen</parameter> :</term>
<listitem><simpara>a <link
linkend="class-gdkscreen"><classname>gtk.gdk.Screen</classname></link>,
or <literal>None</literal> if the screen should be determined by
the widget the menu is attached to.</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.2 and above.</para>
</note>
<para>The <methodname>set_screen</methodname>() method sets the <link
linkend="class-gdkscreen"><classname>gtk.gdk.Screen</classname></link>
specified by <parameter>screen</parameter> on which the menu will be
displayed. If <parameter>screen</parameter> is <literal>None</literal> the
screen is determined by the widget that the menu is attached to.</para>
</refsect2>
<refsect2 id="method-gtkmenu--attach">
<title>gtk.Menu.attach</title>
<programlisting><methodsynopsis language="python">
<methodname>attach</methodname>
<methodparam><parameter role="keyword">child</parameter></methodparam>
<methodparam><parameter role="keyword">left_attach</parameter></methodparam>
<methodparam><parameter role="keyword">right_attach</parameter></methodparam>
<methodparam><parameter role="keyword">top_attach</parameter></methodparam>
<methodparam><parameter role="keyword">bottom_attach</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">child</parameter> :</term>
<listitem><simpara>a <link
linkend="class-gtkmenuitem"><classname>gtk.MenuItem</classname></link>.</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter
role="keyword">left_attach</parameter> :</term>
<listitem><simpara>The column number to attach the left side of
the item to.</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter
role="keyword">right_attach</parameter> :</term>
<listitem><simpara>The column number to attach the right side of
the item to.</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter
role="keyword">top_attach</parameter> :</term>
<listitem><simpara>The row number to attach the top of the item
to.</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter
role="keyword">bottom_attach</parameter> :</term>
<listitem><simpara>The row number to attach the bottom of the item
to.</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.4 and above.</para>
</note>
<para>The <methodname>attach</methodname>() method adds a new <link
linkend="class-gtkmenuitem"><classname>gtk.MenuItem</classname></link>
specified by <parameter>child</parameter> to a (table) menu. The number of
'cells' that an item will occupy is specified by
<parameter>left_attach</parameter>, <parameter>right_attach</parameter>,
<parameter>top_attach</parameter> and
<parameter>bottom_attach</parameter>. These each represent the leftmost,
rightmost, uppermost and lower column and row numbers of the table.
(Columns and rows are indexed from zero).</para>
<para>Note that this function is not related to the <link
linkend="method-gtkmenu--detach"><methodname>detach()</methodname></link>
method.</para>
</refsect2>
<refsect2 id="method-gtkmenu--set-monitor">
<title>gtk.Menu.set_monitor</title>
<programlisting><methodsynopsis language="python">
<methodname>set_monitor</methodname>
<methodparam><parameter role="keyword">monitor_num</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter
role="keyword">monitor_num</parameter> :</term>
<listitem><simpara>the number of the monitor on which the menu
should be popped up</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.4 and above.</para>
</note>
<para>The <methodname>set_monitor</methodname>() method informs
<literal>GTK</literal>+ on which monitor a menu should be popped up. See
the <link
linkend="method-gdkscreen--get-monitor-geometry"><methodname>gtk.gdk.Screen.get_monitor_geometry()</methodname></link>
method for more information.</para>
<para>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.</para>
</refsect2>
<refsect2 id="method-gtkmenu--get-monitor">
<title>gtk.Menu.get_monitor</title>
<programlisting><methodsynopsis language="python">
<methodname>get_monitor</methodname>
<methodparam></methodparam> </methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>the number of the monitor on which the menu should
be popped up or -1, if no monitor has been set </simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.14 and above.</para>
</note>
<para>
The <methodname>get_monitor</methodname>() method returns
the number of the monitor on which to show the menu.
</para>
</refsect2>
<refsect2 id="method-gtkmenu--set-reserve-toggle-size">
<title>gtk.Menu.set_reserve_toggle_size</title>
<programlisting><methodsynopsis language="python">
<methodname>set_reserve_toggle_size</methodname>
<methodparam><parameter role="keyword">reserve_toggle_size</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">reserve_toggle_size</parameter> :</term>
<listitem><simpara><literal>True</literal> to reserve size for toggles.</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.22 and above.</para>
</note>
<para>The <methodname>set_reserve_toggle_size</methodname>() method sets whether the menu
should reserve space for drawing toggles or icons, regardless of their actual presence.</para>
</refsect2>
<refsect2 id="method-gtkmenu--get-reserve-toggle-size">
<title>gtk.Menu.get_reserve_toggle_size</title>
<programlisting><methodsynopsis language="python">
<methodname>get_reserve_toggle_size</methodname>
<methodparam></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>Whether the menu reserves toggle space.</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.22 and above.</para>
</note>
<para>The <methodname>get_reserve_toggle_size</methodname>() method returns whether the menu
reserves space for toggles and icons, regardless of their actual presence.</para>
</refsect2>
</refsect1>
<refsect1>
<title>Signals</title>
<refsect2 id="signal-gtkmenu--move-scroll">
<title>The "move_scroll" gtk.Menu Signal</title>
<programlisting><methodsynopsis language="python">
<methodname>callback</methodname>
<methodparam><parameter>menu</parameter></methodparam>
<methodparam><parameter>type</parameter></methodparam>
<methodparam><parameter>user_param1</parameter></methodparam>
<methodparam><parameter>...</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter>menu</parameter> :</term>
<listitem><simpara>the menu that received the
signal</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter>type</parameter> :</term>
<listitem><simpara>the type of scroll that is requested</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter>user_param1</parameter> :</term>
<listitem><simpara>the first user parameter (if any) specified
with the <link
linkend="method-gobject--connect"><methodname>connect</methodname>()</link>
method</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter>...</parameter> :</term>
<listitem><simpara>additional user parameters (if
any)</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This signal is available in GTK+ 2.2 and above.</para>
</note>
<para>The "move_scroll" signal is emitted when the user attempts to
scroll the menu. <parameter>type</parameter> should be one of the <xref
linkend="gtk-scroll-step-constants"
endterm="gtk-scroll-step-constants-title"></xref>.</para>
</refsect2>
</refsect1>
</refentry>
|