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
|
<?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-gtkdialog">
<refnamediv>
<refname>gtk.Dialog</refname>
<refpurpose>popup windows for user information and action</refpurpose>
</refnamediv>
<refsect1>
<title>Synopsis</title>
<classsynopsis language="python">
<ooclass><classname>gtk.Dialog</classname></ooclass>
<ooclass><classname><link linkend="class-gtkwindow">gtk.Window</link></classname></ooclass>
<constructorsynopsis language="python">
<methodname><link linkend="constructor-gtkdialog">gtk.Dialog</link></methodname>
<methodparam><parameter role="keyword">title</parameter><initializer>None</initializer></methodparam>
<methodparam><parameter role="keyword">parent</parameter><initializer>None</initializer></methodparam>
<methodparam><parameter role="keyword">flags</parameter><initializer>0</initializer></methodparam>
<methodparam><parameter role="keyword">buttons</parameter><initializer>None</initializer></methodparam>
</constructorsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkdialog--add-action-widget">add_action_widget</link></methodname>
<methodparam><parameter role="keyword">child</parameter></methodparam>
<methodparam><parameter role="keyword">response_id</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkdialog--add-button">add_button</link></methodname>
<methodparam><parameter role="keyword">button_text</parameter></methodparam>
<methodparam><parameter role="keyword">response_id</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkdialog--add-buttons">add_buttons</link></methodname>
<methodparam><parameter>...</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkdialog--set-response-sensitive">set_response_sensitive</link></methodname>
<methodparam><parameter role="keyword">response_id</parameter></methodparam>
<methodparam><parameter role="keyword">setting</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkdialog--set-default-response">set_default_response</link></methodname>
<methodparam><parameter role="keyword">response_id</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkdialog--set-has-separator">set_has_separator</link></methodname>
<methodparam><parameter role="keyword">setting</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkdialog--get-has-separator">get_has_separator</link></methodname>
<methodparam></methodparam> </methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkdialog--response">response</link></methodname>
<methodparam><parameter role="keyword">response_id</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkdialog--run">run</link></methodname>
<methodparam></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkdialog--set-alternative-button-order">set_alternative_button_order</link></methodname>
<methodparam><parameter role="keyword">new_order</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkdialog--get-response-for-widget">get_response_for_widget</link></methodname>
<methodparam><parameter role="keyword">widget</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkdialog--get-widget-for-response">get_widget_for_response</link></methodname>
<methodparam><parameter role="keyword">response_id</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkdialog--get-action-area">get_action_area</link></methodname>
<methodparam></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkdialog--get-content-area">get_content_area</link></methodname>
<methodparam></methodparam>
</methodsynopsis>
</classsynopsis>
<programlisting>
<emphasis role="bold">Functions</emphasis>
<methodsynopsis language="python">
<methodname><link linkend="function-gtk--alternative-dialog-button-order">gtk.alternative_dialog_button_order</link></methodname>
<methodparam><parameter role="keyword">screen</parameter><initializer>None</initializer></methodparam>
</methodsynopsis></programlisting>
</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-gtkbin">gtk.Bin</link>
+-- <link linkend="class-gtkwindow">gtk.Window</link>
+-- <link linkend="class-gtkdialog">gtk.Dialog</link>
</synopsis>
</refsect1>
<refsect1>
<title>Implemented Interfaces</title>
<para>
<link linkend="class-gtkdialog"><classname>gtk.Dialog</classname></link>
implements
<link linkend="class-gtkbuildable"><classname>gtk.Buildable</classname></link>
</para>
</refsect1>
<refsect1 id="properties-gtkdialog">
<title>gtk.Dialog 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-gtkwindow">gtk.Window 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="3.5in"/>
<tbody>
<row valign="top">
<entry>"has-separator"</entry>
<entry>Read/Write</entry>
<entry>If <literal>True</literal>, the dialog has a separator bar above its
buttons. This property has been deprecated since GTK+ 2.22 and should not
be used in newly-written code.</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</blockquote>
</refsect1>
<refsect1 id="style-properties-gtkdialog">
<title>gtk.Dialog Style Properties</title>
<para><link linkend="style-properties-gtkwidget">gtk.Widget Style 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="3.5in"/>
<tbody>
<row valign="top">
<entry>"action-area-border"</entry>
<entry>Read</entry>
<entry>The width of the vborder around the button area in pixels.</entry>
</row>
<row valign="top">
<entry>"button-spacing"</entry>
<entry>Read</entry>
<entry>The spacing between buttons in pixels.</entry>
</row>
<row valign="top">
<entry>"content-area-spacing"</entry>
<entry>Read</entry>
<entry>The default spacing used between elements of the content area of the dialog, as returned by
<methodname><link linkend="method-gtkdialog--get-content-area">gtk.Dialog.get_content_area</link></methodname>(),
unless <methodname><link linkend="method-gtkbox--set-spacing">gtk.Box.set_spacing</link></methodname>()
was called on that widget directly. Allowed values: >= 0. Default value: 0. This property is available in GTK+ 2.16 and above.</entry>
</row>
<row valign="top">
<entry>"content-area-border"</entry>
<entry>Read</entry>
<entry>The width of the border around the main dialog area in pixels.</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</blockquote>
</refsect1>
<refsect1>
<title>Attributes</title>
<blockquote role="properties">
<informaltable pgwide="1" frame="none">
<tgroup cols="3">
<?dbhtml cellpadding="5"?>
<colspec column="1" colwidth="1in"/>
<colspec column="2" colwidth="1in"/>
<colspec column="3" colwidth="3.5in"/>
<tbody>
<row valign="top">
<entry>"vbox"</entry>
<entry>Read</entry>
<entry>A <link linkend="class-gtkvbox"><classname>gtk.VBox</classname></link> that is the main container of the dialog - all the other widgets are packed in it.</entry>
</row>
<row valign="top">
<entry>"action_area"</entry>
<entry>Read</entry>
<entry>A <link linkend="class-gtkhbox"><classname>gtk.HBox</classname></link> that contains the buttons of the dialog.</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</blockquote>
</refsect1>
<refsect1 id="signal-prototypes-gtkdialog">
<title>gtk.Dialog 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-gtkwindow">gtk.Window Signal Prototypes</link></para>
<variablelist>
<varlistentry>
<term>"<link linkend="signal-gtkdialog--close">close</link>"</term>
<listitem>
<methodsynopsis language="python"><methodname>callback</methodname>
<methodparam><parameter>dialog</parameter></methodparam>
<methodparam><parameter>user_param1</parameter></methodparam>
<methodparam><parameter>...</parameter></methodparam>
</methodsynopsis>
</listitem>
</varlistentry>
<varlistentry>
<term>"<link linkend="signal-gtkdialog--response">response</link>"</term>
<listitem>
<methodsynopsis language="python">
<methodname>callback</methodname>
<methodparam><parameter>dialog</parameter></methodparam>
<methodparam><parameter>response_id</parameter></methodparam>
<methodparam><parameter>user_param1</parameter></methodparam>
<methodparam><parameter>...</parameter></methodparam>
</methodsynopsis>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>Dialog boxes are a convenient way to prompt the user for a small
amount of input, e.g. to display a message, ask a question, or anything
else that does not require extensive effort on the user's part. Dialogs
are organized as a window split vertically. The top section is a <link
linkend="class-gtkvbox"><classname>gtk.VBox</classname></link>, and is
where widgets such as a <link
linkend="class-gtklabel"><classname>gtk.Label</classname></link> or a
<link linkend="class-gtkentry"><classname>gtk.Entry</classname></link>
should be packed. The bottom area is known as the action_area which is
generally used for packing buttons into the dialog which may perform
functions such as cancel, ok, or apply. The two areas are separated by a
<link
linkend="class-gtkhseparator"><classname>gtk.HSeparator</classname></link>.</para>
<para>The <link
linkend="class-gtkdialog"><classname>gtk.Dialog</classname></link> boxes
are created with a call to <link
linkend="constructor-gtkdialog"><methodname>gtk.Dialog</methodname></link>()
that sets the dialog title, some convenient flags, and adds simple
buttons. In a newly created dialog, the two primary areas of the window
can be accessed as the vbox and action_area attributes, as can be seen
from the example, below.</para>
<programlisting>
import gtk
label = gtk.Label("Nice label")
dialog = gtk.Dialog("My dialog",
None,
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
dialog.vbox.pack_start(label)
label.show()
checkbox = gtk.CheckButton("Useless checkbox")
dialog.action_area.pack_end(checkbox)
checkbox.show()
response = dialog.run()
dialog.destroy()
</programlisting>
<para>A modal dialog (that is, one which freezes the
rest of the application from user input), can be created by passing the
<literal>gtk.DIALOG_MODAL</literal> flag to the <link
linkend="constructor-gtkdialog"><methodname>gtk.Dialog</methodname>()</link>
constructor or by calling <link
linkend="method-gtkwindow--set-modal"><methodname>set_modal</methodname>()</link>
on the dialog.</para>
<para>If you add buttons to <link
linkend="class-gtkdialog"><classname>gtk.Dialog</classname></link> using
<link
linkend="constructor-gtkdialog"><methodname>gtk.Dialog</methodname>()</link>,
<link
linkend="method-gtkdialog--add-button"><methodname>add_button</methodname>()</link>,
or <link
linkend="method-gtkdialog--add-action-widget"><methodname>add_action_widget</methodname>()</link>,
clicking the button will emit a signal called "response" with a response
ID that you specified. PyGTK will never assign a meaning to positive
response IDs; these are entirely user-defined. But for convenience, you
can use the pre-defined <xref linkend="gtk-response-type-constants"
endterm="gtk-response-type-constants-title"></xref> (these all have
values less than zero).</para>
<para>If a dialog receives a delete event, the "response" signal will be
emitted with a response ID of
<literal>gtk.RESPONSE_DELETE_EVENT</literal>.</para>
<para>If you want to block waiting for a dialog to return before
returning control flow to your code, you can call <link
linkend="method-gtkdialog--run"><methodname>run</methodname>()</link>. This
function enters a recursive main loop and waits for the user to respond
to the dialog, returning the response ID corresponding to the button the
user clicked.</para>
</refsect1>
<refsect1 id="constructor-gtkdialog">
<title>Constructor</title>
<programlisting><constructorsynopsis language="python">
<methodname>gtk.Dialog</methodname>
<methodparam><parameter role="keyword">title</parameter><initializer>None</initializer></methodparam>
<methodparam><parameter role="keyword">parent</parameter><initializer>None</initializer></methodparam>
<methodparam><parameter role="keyword">flags</parameter><initializer>0</initializer></methodparam>
<methodparam><parameter role="keyword">buttons</parameter><initializer>None</initializer></methodparam>
</constructorsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">title</parameter> :</term>
<listitem><simpara>The title of the dialog, or <literal>None</literal></simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter role="keyword">parent</parameter> :</term>
<listitem><simpara>The transient parent of the dialog, or <literal>None</literal></simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter role="keyword">flags</parameter> :</term>
<listitem><simpara>flags that control the operation of the dialog</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter role="keyword">buttons</parameter> :</term>
<listitem><simpara>a tuple containing button text/response id pairs or <literal>None</literal></simpara></listitem>
</varlistentry>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>a new <link linkend="class-gtkdialog"><classname>gtk.Dialog</classname></link></simpara></listitem>
</varlistentry>
</variablelist>
<para>Creates a new <link
linkend="class-gtkdialog"><classname>gtk.Dialog</classname></link> with the
title text specified by <parameter>title</parameter> (or
<literal>None</literal> for the default title; see <link
linkend="method-gtkwindow--set-title"><methodname>gtk.Window.set_title</methodname>()</link>)
and transient parent window specified by <parameter>parent</parameter> (or
<literal>None</literal> for none; see <link
linkend="method-gtkwindow--set-transient-for"><methodname>gtk.Window.set_transient_for</methodname>()</link>).
The <parameter>flags</parameter> argument can be used to make the dialog
modal (<literal>gtk.DIALOG_MODAL</literal>) and/or to have it destroyed
along with its transient parent
(<literal>gtk.DIALOG_DESTROY_WITH_PARENT</literal>) and/or remove the
separator (<literal>gtk.DIALOG_NO_SEPARATOR</literal>) (see the <xref
linkend="gtk-dialog-flag-constants"
endterm="gtk-dialog-flag-constants-title"></xref> for more
information). After <parameter>flags</parameter>, a tuple of button
text/response ID pairs should be listed, or <literal>None</literal> (the
default value) if no buttons are needed. The button text can be either a
stock ID such as <literal>gtk.STOCK_OK</literal>, or some arbitrary text. A
response ID can be any positive number, or one of the pre-defined <xref
linkend="gtk-response-type-constants"
endterm="gtk-response-type-constants-title"></xref>.</para>
<para>If the user clicks one of these dialog buttons, the <link
linkend="class-gtkdialog"><classname>gtk.Dialog</classname></link> will emit
the "response" signal with the corresponding response ID. If a <link
linkend="class-gtkdialog"><classname>gtk.Dialog</classname></link> receives
the "delete_event" signal, it will emit "response" with a response ID of
<literal>gtk.RESPONSE_DELETE_EVENT</literal>. However, destroying a dialog
does not emit the "response" signal; so be careful relying on "response"
when using the <literal>gtk.DIALOG_DESTROY_WITH_PARENT</literal> flag.
Buttons are added from left to right, so the first button in the list will
be the leftmost button in the dialog.</para>
<para>Here's a simple example:</para>
<programlisting>
dialog = gtk.Dialog("My dialog",
main_app_window,
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
</programlisting>
</refsect1>
<refsect1>
<title>Methods</title>
<refsect2 id="method-gtkdialog--add-action-widget">
<title>gtk.Dialog.add_action_widget</title>
<programlisting><methodsynopsis language="python">
<methodname>add_action_widget</methodname>
<methodparam><parameter role="keyword">child</parameter></methodparam>
<methodparam><parameter role="keyword">response_id</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">child</parameter> :</term>
<listitem><simpara>an activatable widget</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter role="keyword">response_id</parameter> :</term>
<listitem><simpara>a response ID</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>add_action_widget</methodname>() method adds an
activatable widget to the action area of a <link
linkend="class-gtkdialog"><classname>gtk.Dialog</classname></link>,
connecting a signal handler that will emit the "response" signal on the
dialog when the widget is activated. The widget is appended to the end of
the dialog's action area. If you want to add a non-activatable widget,
simply pack it into the <literal>action_area</literal>.</para>
</refsect2>
<refsect2 id="method-gtkdialog--add-button">
<title>gtk.Dialog.add_button</title>
<programlisting><methodsynopsis language="python">
<methodname>add_button</methodname>
<methodparam><parameter role="keyword">button_text</parameter></methodparam>
<methodparam><parameter role="keyword">response_id</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">button_text</parameter> :</term>
<listitem><simpara>the text of the button, or a stock ID</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter role="keyword">response_id</parameter> :</term>
<listitem><simpara>the response ID for the button</simpara></listitem>
</varlistentry>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>the button widget that was added</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>add_button</methodname>() method adds a button
with the text specified by <parameter>button_text</parameter> (or a stock
button, if <parameter>button_text</parameter> is a stock ID) and sets things
up so that clicking the button will emit the "response" signal with the
specified <parameter>response_id</parameter>. The button is appended to the
end of the dialog's action area. The button widget is returned, but usually
you don't need it.</para>
</refsect2>
<refsect2 id="method-gtkdialog--add-buttons">
<title>gtk.Dialog.add_buttons</title>
<programlisting><methodsynopsis language="python">
<methodname>add_buttons</methodname>
<methodparam><parameter>...</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter>...</parameter> :</term>
<listitem><simpara>one or more pairs of button specifiers: button text (or stock ID) and a response id</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>add_buttons</methodname>() method adds several
buttons to the <link
linkend="class-gtkdialog"><classname>gtk.Dialog</classname></link> using the
button data passed as arguments to the method. This method is the same as
calling the <link
linkend="method-gtkdialog--add-button"><methodname>gtk.Dialog.add_button</methodname>()</link>
repeatedly. The button data pairs - button text (or stock ID) and a response
ID integer are passed individually. For example:</para>
<programlisting>
dialog.add_buttons(gtk.STOCK_OPEN, 42, "Close", gtk.RESPONSE_CLOSE)
</programlisting>
<para>will add "Open" and "Close" buttons to <parameter>dialog</parameter>.</para>
</refsect2>
<refsect2 id="method-gtkdialog--set-response-sensitive">
<title>gtk.Dialog.set_response_sensitive</title>
<programlisting><methodsynopsis language="python">
<methodname>set_response_sensitive</methodname>
<methodparam><parameter role="keyword">response_id</parameter></methodparam>
<methodparam><parameter role="keyword">setting</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">response_id</parameter> :</term>
<listitem><simpara>a response ID</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter role="keyword">setting</parameter> :</term>
<listitem><simpara>the new value for sensitive</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>set_response_sensitive</methodname>() method
calls the <link
linkend="method-gtkwidget--set-sensitive"><methodname>gtk.Window.set_sensitive</methodname>()</link>
method with the specified <parameter>response_id</parameter> for each widget
in the dialog's action area. This method is a convenience function to
sensitize/desensitize all dialog buttons at once.</para>
</refsect2>
<refsect2 id="method-gtkdialog--set-default-response">
<title>gtk.Dialog.set_default_response</title>
<programlisting><methodsynopsis language="python">
<methodname>set_default_response</methodname>
<methodparam><parameter role="keyword">response_id</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">response_id</parameter> :</term>
<listitem><simpara>a response ID</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>set_default_response</methodname>() method sets
the last widget in the dialog's action area with the specified
<parameter>response_id</parameter> as the default widget for the dialog.
Pressing <keycap>Enter</keycap> normally activates the default
widget.</para>
</refsect2>
<refsect2 id="method-gtkdialog--set-has-separator">
<title>gtk.Dialog.set_has_separator</title>
<programlisting><methodsynopsis language="python">
<methodname>set_has_separator</methodname>
<methodparam><parameter role="keyword">setting</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">setting</parameter> :</term>
<listitem><simpara>If <literal>True</literal> use a separator</simpara></listitem>
</varlistentry>
</variablelist>
<warning>
<para>
This method is deprecated in PyGTK 2.22 and above and should not be
used in newly-written code.
</para>
</warning>
<para>The <methodname>set_has_separator</methodname>() method sets the
"has-separator" property to the value of <parameter>setting</parameter>. If
<parameter>setting</parameter> is <literal>True</literal> (the default
value) the dialog has a separator above the buttons.</para>
</refsect2>
<refsect2 id="method-gtkdialog--get-has-separator">
<title>gtk.Dialog.get_has_separator</title>
<programlisting><methodsynopsis language="python">
<methodname>get_has_separator</methodname>
<methodparam></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>the value of the "has-separator" property</simpara></listitem>
</varlistentry>
</variablelist>
<warning>
<para>
This method is deprecated in PyGTK 2.22 and above and should not be
used in newly-written code.
</para>
</warning>
<para>The <methodname>get_has_separator</methodname>() method returns
the value of the "has-separator" property.</para>
</refsect2>
<refsect2 id="method-gtkdialog--response">
<title>gtk.Dialog.response</title>
<programlisting><methodsynopsis language="python">
<methodname>response</methodname>
<methodparam><parameter role="keyword">response_id</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">response_id</parameter> :</term>
<listitem><simpara>response ID</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>response</methodname>() method emits the
"response" signal with the value specified in
<parameter>response_id</parameter>. This method is used to indicate that the
user has responded to the dialog in some way; typically either you or <link
linkend="method-gtkdialog--run"><function>gtk.Dialog.run()</function></link>
will be monitoring the "response" signal and take appropriate action.</para>
</refsect2>
<refsect2 id="method-gtkdialog--run">
<title>gtk.Dialog.run</title>
<programlisting><methodsynopsis language="python">
<methodname>run</methodname>
<methodparam></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>a response ID</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>run</methodname>() method blocks in a recursive
main loop until the dialog either emits the "response" signal, or is
destroyed. If the dialog is destroyed, the <methodname>run</methodname>()
method returns <literal>gtk.RESPONSE_NONE</literal>; otherwise, it returns
the response ID from the "response" signal emission. Before entering the
recursive main loop, the <methodname>run</methodname>() method calls the
<link linkend="method-gtkwidget--show"><methodname>gtk.Widget.show</methodname>()</link>
on the dialog for you. Note that you still need to show any children of the
dialog yourself.</para>
<para>During the <methodname>run</methodname>() method, the default
behavior of "delete_event" is disabled; if the dialog receives a
"delete_event", it will not be destroyed as windows usually are, and the
<methodname>run</methodname>() method will return
<literal>gtk.RESPONSE_DELETE_EVENT</literal>. Also, during the
<methodname>run</methodname>() method the dialog will be modal. You can
force the <methodname>run</methodname>() method to return at any time by
calling <link linkend="method-gtkdialog--response"><methodname>response</methodname>()</link>
to emit the "response" signal. Destroying the dialog during the
<methodname>run</methodname>() method is a very bad idea, because your
post-run code won't know whether the dialog was destroyed or not.</para>
<para>After the <methodname>run</methodname>() method returns, you are
responsible for hiding or destroying the dialog as needed.</para>
</refsect2>
<refsect2 id="method-gtkdialog--set-alternative-button-order">
<title>gtk.Dialog.set_alternative_button_order</title>
<programlisting><methodsynopsis language="python">
<methodname>set_alternative_button_order</methodname>
<methodparam><parameter role="keyword">new_order</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">new_order</parameter> :</term>
<listitem><simpara>a sequence containing response id integer values</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.6 and above.</para>
</note>
<para>The <methodname>set_alternative_button_order</methodname>()
method sets an alternative button order for the dialog based on the sequence
of response ids specified by <parameter>new_order</parameter>. If the
"gtk-alternative-button-order" property of the <link
linkend="class-gtksettings"><classname>gtk.Settings</classname></link>
object is set to <literal>True</literal>, the dialog buttons are reordered
according to the order of the response ids passed to this method.</para>
<para>By default, GTK+ dialogs use the button order advocated by the
Gnome Human Interface Guidelines with the affirmative button at the far
right, and the cancel button left of it. But the builtin GTK+ dialogs and
<link linkend="class-gtkmessagedialog"><classname>gtk.MessageDialog</classname></link>s
do provide an alternative button order, which is more suitable on some
platforms, e.g. Windows.</para>
<para>Use this method after adding all the buttons to your dialog,
as the following example shows:</para>
<programlisting>
settings = gtk.settings_get_default()
settings.set_property('gtk-alternative-button-order', True)
dialog = gtk.Dialog()
cancel_button = dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
ok_button = dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
ok_button.grab_default()
help_button = dialog.add_button(gtk.STOCK_HELP, gtk.RESPONSE_HELP)
dialog.set_alternative_button_order([gtk.RESPONSE_OK, gtk.RESPONSE_CANCEL,
gtk.RESPONSE_HELP])
</programlisting>
</refsect2>
<refsect2 id="method-gtkdialog--get-response-for-widget">
<title>gtk.Dialog.get_response_for_widget</title>
<programlisting><methodsynopsis language="python">
<methodname>get_response_for_widget</methodname>
<methodparam><parameter role="keyword">widget</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">widget</parameter> :</term>
<listitem><simpara>a widget in the action area of the dialog</simpara></listitem>
</varlistentry>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara> the response id of <parameter>widget</parameter>, or gtk.RESPONSE_NONE if the widget doesn't have a response id set.</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.8 and above.</para>
</note>
<para>The <methodname>get_response_for_widget</methodname>() method
returns the response id of the widget specified by
<parameter>widget</parameter> in the action area of the dialog.</para>
</refsect2>
<refsect2 id="method-gtkdialog--get-widget-for-response">
<title>gtk.Dialog.get_widget_for_response</title>
<programlisting><methodsynopsis language="python">
<methodname>get_widget_for_response</methodname>
<methodparam><parameter role="keyword">response_id</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">response_id</parameter> :</term>
<listitem><simpara>the response ID used by the dialog widget </simpara></listitem>
</varlistentry>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>the widget button that uses the given response_id, or <literal>None</literal>.</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.22 and above.</para>
</note>
<para>The <methodname>get_widget_for_response</methodname>() method returns the widget button
that uses the given response ID in the action area of a dialog, or <literal>None</literal>.</para>
</refsect2>
<refsect2 id="method-gtkdialog--get-action-area">
<title>gtk.Dialog.get_action_area</title>
<programlisting><methodsynopsis language="python">
<methodname>get_action_area</methodname>
<methodparam></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>the action area.</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.14 and above.</para>
</note>
<para>The <methodname>get_action_area</methodname>() method
returns the action area of dialog.</para>
</refsect2>
<refsect2 id="method-gtkdialog--get-content-area">
<title>gtk.Dialog.get_content_area</title>
<programlisting><methodsynopsis language="python">
<methodname>get_content_area</methodname>
<methodparam></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>the content area <link linkend="class-gdkscreen"><classname>gtk.VBox</classname></link>.</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.14 and above.</para>
</note>
<para>The <methodname>get_content_area</methodname>() method
returns the content area of dialog.</para>
</refsect2>
</refsect1>
<refsect1>
<title>Functions</title>
<refsect2 id="function-gtk--alternative-dialog-button-order">
<title>gtk.alternative_dialog_button_order</title>
<programlisting><methodsynopsis language="python">
<methodname>gtk.alternative_dialog_button_order</methodname>
<methodparam><parameter role="keyword">screen</parameter><initializer>None</initializer></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">screen</parameter> :</term>
<listitem><simpara>the <link linkend="class-gdkscreen"><classname>gtk.gdk.Screen</classname></link> or <literal>None</literal> to use the default screen</simpara></listitem>
</varlistentry>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara><literal>True</literal> if the alternative button order should be used</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This function is available in PyGTK 2.10 and above.</para>
</note>
<para>The <function>gtk.alternative_dialog_button_order</function>()
returns <literal>True</literal> if the alternative button order should be
used for the <link linkend="class-gdkscreen"><classname>gtk.gdk.Screen</classname></link>
specified by <parameter>screen</parameter>. If <parameter>screen</parameter>
is <literal>None</literal> the default <link
linkend="class-gdkscreen"><classname>gtk.gdk.Screen</classname></link> is used.</para>
</refsect2>
</refsect1>
<refsect1>
<title>Signals</title>
<refsect2 id="signal-gtkdialog--close">
<title>The "close" gtk.Dialog Signal</title>
<programlisting><methodsynopsis language="python">
<methodname>callback</methodname>
<methodparam><parameter>dialog</parameter></methodparam>
<methodparam><parameter>user_param1</parameter></methodparam>
<methodparam><parameter>...</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter>dialog</parameter> :</term>
<listitem><simpara>the dialog that received the signal</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>
<para>The "close" signal is emitted when the dialog is closed.</para>
</refsect2>
<refsect2 id="signal-gtkdialog--response">
<title>The "response" gtk.Dialog Signal</title>
<programlisting><methodsynopsis language="python">
<methodname>callback</methodname>
<methodparam><parameter>dialog</parameter></methodparam>
<methodparam><parameter>response_id</parameter></methodparam>
<methodparam><parameter>user_param1</parameter></methodparam>
<methodparam><parameter>...</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter>dialog</parameter> :</term>
<listitem><simpara>the dialog that received the signal</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter>response_id</parameter> :</term>
<listitem><simpara>the response id received by the dialog</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>
<para>The "response" signal is emitted when an action_area widget is
activated (button "clicked"), the dialog receives a delete_event or the
application calls the <link
linkend="method-gtkdialog--response"><methodname>response</methodname>()</link>
method. When a delete_event triggers the "response" signal the
<parameter>response_id</parameter> will be
<literal>gtk.RESPONSE_DELETE_EVENT</literal>.</para>
</refsect2>
</refsect1>
</refentry>
|