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
|
<?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-gladexml">
<refnamediv>
<refname>gtk.glade.XML</refname>
<refpurpose>Allows dynamic loading of user interfaces
from XML descriptions.</refpurpose>
</refnamediv>
<refsect1>
<title>Synopsis</title>
<classsynopsis language="python">
<ooclass><classname>gtk.glade.XML</classname></ooclass>
<ooclass><classname><link
linkend="class-gobject">gobject.GObject</link></classname></ooclass>
<constructorsynopsis language="python">
<methodname><link
linkend="constructor-gladexml">gtk.glade.XML</link></methodname>
<methodparam><parameter role="keyword">fname</parameter></methodparam>
<methodparam><parameter role="keyword">root</parameter><initializer><literal>None</literal></initializer></methodparam>
<methodparam><parameter role="keyword">domain</parameter><initializer><literal>""</literal></initializer></methodparam>
<methodparam><parameter role="keyword">typedict</parameter><initializer><literal>{}</literal></initializer></methodparam> </constructorsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gladexml--signal-connect">signal_connect</link></methodname>
<methodparam><parameter>handler_name</parameter></methodparam>
<methodparam><parameter>func</parameter></methodparam>
</methodsynopsis><methodsynopsis language="python">
<methodname><link linkend="method-gladexml--signal-autoconnect">signal_autoconnect</link></methodname>
<methodparam><parameter role="keyword">dict</parameter></methodparam>
</methodsynopsis><methodsynopsis language="python">
<methodname><link linkend="method-gladexml--get-widget">get_widget</link></methodname>
<methodparam><parameter role="keyword">name</parameter></methodparam>
</methodsynopsis><methodsynopsis language="python">
<methodname><link linkend="method-gladexml--get-widget-prefix">get_widget_prefix</link></methodname>
<methodparam><parameter role="keyword">name</parameter></methodparam>
</methodsynopsis><methodsynopsis language="python">
<methodname><link linkend="method-gladexml--relative-file">relative_file</link></methodname>
<methodparam><parameter role="keyword">filename</parameter></methodparam>
</methodsynopsis>
</classsynopsis>
<programlisting>
<emphasis role="bold">Functions</emphasis>
<methodsynopsis language="python">
<methodname><link linkend="function-glade--xml-new-from-buffer">gtk.glade.xml_new_from_buffer</link></methodname>
<methodparam><parameter role="keyword">buffer</parameter></methodparam>
<methodparam><parameter role="keyword">size</parameter></methodparam>
<methodparam><parameter role="keyword">root</parameter><initializer><literal>""</literal></initializer></methodparam>
<methodparam><parameter role="keyword">domain</parameter><initializer><literal>""</literal></initializer></methodparam>
<methodparam><parameter role="keyword">typedict</parameter><initializer><literal>{}</literal></initializer></methodparam>
</methodsynopsis><methodsynopsis language="python">
<methodname><link linkend="function-glade--get-widget-name">gtk.glade.get_widget_name</link></methodname>
<methodparam><parameter role="keyword">widget</parameter></methodparam>
</methodsynopsis><methodsynopsis language="python">
<methodname><link linkend="function-glade--get-widget-tree">gtk.glade.get_widget_tree</link></methodname>
<methodparam><parameter role="keyword">widget</parameter></methodparam>
</methodsynopsis><methodsynopsis language="python">
<methodname><link linkend="function-glade--set-custom-handler">gtk.glade.set_custom_handler</link></methodname>
<methodparam><parameter>handler</parameter></methodparam>
<methodparam><parameter>user_data</parameter></methodparam>
</methodsynopsis><methodsynopsis language="python">
<methodname><link linkend="function-glade--bindtextdomain">gtk.glade.bindtextdomain</link></methodname>
<methodparam><parameter role="keyword">domainname</parameter></methodparam>
<methodparam><parameter role="keyword">dirname</parameter><initializer><literal>""</literal></initializer></methodparam>
</methodsynopsis><methodsynopsis language="python">
<methodname><link linkend="function-glade--textdomain">gtk.glade.textdomain</link></methodname>
<methodparam><parameter role="keyword">domainname</parameter><initializer><literal>""</literal></initializer></methodparam>
</methodsynopsis><methodsynopsis language="python">
<methodname><link linkend="function-glade--set-custom-widget-callbacks">gtk.glade.set_custom_widget_callbacks</link></methodname>
<methodparam><parameter role="keyword">dict</parameter></methodparam>
</methodsynopsis></programlisting>
</refsect1>
<refsect1>
<title>Ancestry</title>
<synopsis>+-- <link linkend="class-gobject">gobject.GObject</link>
+-- <link linkend="class-gladexml">gtk.glade.XML</link>
</synopsis>
</refsect1>
<refsect1 id="signal-prototypes-gladexml">
<title>gtk.glade.XML Signal Prototypes</title>
<para><link linkend="signal-prototypes-gobject">gobject.GObject Signal Prototypes</link></para>
</refsect1>
<refsect1>
<title>Description</title>
<para>This object represents an `instantiation' of an XML interface
description. When one of these objects is created, the XML file is read,
and the interface is created. The <link
linkend="class-gladexml"><classname>gtk.glade.XML</classname></link> object
then provides an interface for accessing the widgets in the interface by the
names assigned to them inside the XML description.</para>
<para>The <link
linkend="class-gladexml"><classname>gtk.glade.XML</classname></link> object
can also be used to connect handlers to the named signals in the
description. Libglade also provides an interface by which it can look up
the signal handler names in the program's symbol table and automatically
connect as many handlers up as it can that way.</para>
</refsect1>
<refsect1 id="constructor-gladexml">
<title>Constructor</title>
<programlisting><constructorsynopsis language="python">
<methodname>gtk.glade.XML</methodname>
<methodparam><parameter role="keyword">fname</parameter></methodparam>
<methodparam><parameter role="keyword">root</parameter><initializer><literal>None</literal></initializer></methodparam>
<methodparam><parameter role="keyword">domain</parameter><initializer><literal>""</literal></initializer></methodparam>
<methodparam><parameter role="keyword">typedict</parameter><initializer><literal>{}</literal></initializer></methodparam>
</constructorsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">fname</parameter> :</term>
<listitem><simpara>the XML file name</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter role="keyword">root</parameter> :</term>
<listitem><simpara>the widget node in <parameter>fname</parameter> to
start building from (or <literal>None</literal>)</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter role="keyword">domain</parameter> :</term>
<listitem><simpara>the translation domain for the XML file (or
<literal>""</literal> for default)</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter role="keyword">typedict</parameter> :</term>
<listitem><simpara>A dictionary used to lookup types (or
<literal>{}</literal> for default)</simpara></listitem>
</varlistentry>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem>
<simpara>a new <link
linkend="class-gladexml"><classname>gtk.glade.XML</classname></link>
object</simpara>
</listitem>
</varlistentry>
</variablelist>
<para>Creates a new <link
linkend="class-gladexml"><classname>gtk.glade.XML</classname></link> object
(and the corresponding widgets) from the XML file specified by
<parameter>fname</parameter>. Optionally it will only build the interface
from the widget node specified by <parameter>root</parameter> (if it is not
<literal>None</literal>). This feature is useful if you only want to build
say a toolbar or menu from the XML file, but not the window it is embedded
in. Note also that the XML parse tree is cached to speed up creating another
<link linkend="class-gladexml"><classname>gtk.glade.XML</classname></link>
object for the same file.</para>
</refsect1>
<refsect1>
<title>Methods</title>
<refsect2 id="method-gladexml--signal-connect">
<title>gtk.glade.XML.signal_connect</title>
<programlisting><methodsynopsis language="python">
<methodname>signal_connect</methodname>
<methodparam><parameter>handler_name</parameter></methodparam>
<methodparam><parameter>func</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter>handler_name</parameter> :</term>
<listitem><simpara>the signal handler name</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter>func</parameter> :</term>
<listitem><simpara>the signal handler function</simpara></listitem>
</varlistentry>
</variablelist>
<para>In the glade interface descriptions, signal handlers are
specified for widgets by name. The <methodname>signal_connect</methodname>()
method allows you to connect a callback specified by
<parameter>func</parameter> to all signals in the <link
linkend="class-gladexml"><classname>gtk.glade.XML</classname></link> file
with the signal handler name specified by
<parameter>handler_name</parameter>.</para>
</refsect2>
<refsect2 id="method-gladexml--signal-autoconnect">
<title>gtk.glade.XML.signal_autoconnect</title>
<programlisting><methodsynopsis language="python">
<methodname>signal_autoconnect</methodname>
<methodparam><parameter role="keyword">dict</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">dict</parameter> :</term>
<listitem><simpara>a mapping or an instance</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>signal_autoconnect</methodname>() method is a
variation of the <link
linkend="method-gladexml--signal-connect">gtk.glade.XML.signal_connect</link>
method. It uses Python's introspective features to look at the keys (if
<parameter>dict</parameter> is a mapping) or attributes (if
<parameter>dict</parameter> is an instance) and tries to match them with the
signal handler names given in the interface description. The callbacks
referenced by each matched key or attribute are connected to their matching
signals. The argument is called <literal>dict</literal> due to compatibility
reasons since originally only the mapping interface was supported. The
instance variant was introduced in PyGTK 2.0.</para>
</refsect2>
<refsect2 id="method-gladexml--get-widget">
<title>gtk.glade.XML.get_widget</title>
<programlisting><methodsynopsis language="python">
<methodname>get_widget</methodname>
<methodparam><parameter role="keyword">name</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">name</parameter> :</term>
<listitem><simpara>the name of the widget</simpara></listitem>
</varlistentry>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem>
<simpara>the widget matching the name or
<literal>None</literal></simpara>
</listitem>
</varlistentry>
</variablelist>
<para>The <methodname>get_widget</methodname>() method returns a
reference to the <link
linkend="class-gtkwidget"><classname>gtk.Widget</classname></link> specified
by <parameter>name</parameter> in the interface
description. <literal>None</literal> is returned, if
<parameter>name</parameter> doesn't specify a widget in the
interface.</para>
</refsect2>
<refsect2 id="method-gladexml--get-widget-prefix">
<title>gtk.glade.XML.get_widget_prefix</title>
<programlisting><methodsynopsis language="python">
<methodname>get_widget_prefix</methodname>
<methodparam><parameter role="keyword">name</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">name</parameter> :</term>
<listitem><simpara>the prefix the widget names or
<literal>""</literal> for all widgets</simpara></listitem>
</varlistentry>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem>
<simpara>A list of widgets that match <parameter>name</parameter>
as the start of their name or <literal>None</literal></simpara>
</listitem>
</varlistentry>
</variablelist>
<para>The <methodname>get_widget_prefix</methodname>() method returns
a list of interface <link
linkend="class-gtkwidget"><classname>gtk.Widget</classname></link> objects
that have names prefixed by
<parameter>name</parameter>. <literal>None</literal> is returned if no
interface widget names match the prefix <parameter>name</parameter>.</para>
</refsect2>
<refsect2 id="method-gladexml--relative-file">
<title>gtk.glade.XML.relative_file</title>
<programlisting><methodsynopsis language="python">
<methodname>relative_file</methodname>
<methodparam><parameter role="keyword">filename</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">filename</parameter> :</term>
<listitem><simpara>a relative file pathname</simpara></listitem>
</varlistentry>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem>
<simpara>the absolute file pathname</simpara>
</listitem>
</varlistentry>
</variablelist>
<para>The <methodname>relative_file</methodname>() method resolves the
relative pathname specified by <parameter>filename</parameter>, using the
directory of the XML file as a base. If <parameter>filename</parameter>
contains an absolute pathname, then the original file name is
returned.</para>
</refsect2>
</refsect1>
<refsect1>
<title>Functions</title>
<refsect2 id="function-glade--xml-new-from-buffer">
<title>gtk.glade.xml_new_from_buffer</title>
<programlisting><methodsynopsis language="python">
<methodname>gtk.image_new_from_buffer</methodname>
<methodparam><parameter role="keyword">buffer</parameter></methodparam>
<methodparam><parameter role="keyword">size</parameter></methodparam>
<methodparam><parameter role="keyword">root</parameter><initializer><literal>""</literal></initializer></methodparam>
<methodparam><parameter role="keyword">domain</parameter><initializer><literal>""</literal></initializer></methodparam>
<methodparam><parameter role="keyword">typedict</parameter><initializer><literal>{}</literal></initializer></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">buffer</parameter> :</term>
<listitem><simpara>the string containing the XML buffer</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter role="keyword">size</parameter> :</term>
<listitem><simpara>size of the string</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter role="keyword">root</parameter> :</term>
<listitem><simpara>the widget node in fname to start building from
(or <literal>""</literal>)</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter role="keyword">domain</parameter> :</term>
<listitem><simpara>the translation domain for the XML file (or
<literal>""</literal> for default)</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter role="keyword">typedict</parameter> :</term>
<listitem><simpara>A dictionary used to lookup types (or
<literal>{}</literal> for default)</simpara></listitem>
</varlistentry>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem>
<simpara>a new <link
linkend="class-gladexml"><classname>gtk.glade.XML</classname></link>
object.</simpara>
</listitem>
</varlistentry>
</variablelist>
<para>The <function>gtk.glade.xml_new_from_buffer</function>()
function creates a new <link
linkend="class-gladexml"><classname>gtk.glade.XML</classname></link> object
(and the corresponding widgets) from the string specified by
<parameter>buffer</parameter>. Optionally it will only build the interface
from the widget node specified by <parameter>root</parameter> (if it is not
<literal>""</literal>). This feature is useful if you only want to build
say a toolbar or menu from the XML document, but not the window it is
embedded in.</para>
</refsect2>
<refsect2 id="function-glade--get-widget-name">
<title>gtk.glade.get_widget_name</title>
<programlisting><methodsynopsis language="python">
<methodname>gtk.glade.get_widget_name</methodname>
<methodparam><parameter role="keyword">widget</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">widget</parameter> :</term>
<listitem><simpara>a <link
linkend="class-gtkwidget"><classname>gtk.Widget</classname></link></simpara></listitem>
</varlistentry>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem>
<simpara>the name of the widget</simpara>
</listitem>
</varlistentry>
</variablelist>
<para>The <function>gtk.glade.get_widget_name</function>() function
returns the name of the <link
linkend="class-gtkwidget"><classname>gtk.Widget</classname></link> specified
by <parameter>widget</parameter> that was generated by a <link
linkend="class-gladexml"><classname>gtk.glade.XML</classname></link>
object.</para>
</refsect2>
<refsect2 id="function-glade--get-widget-tree">
<title>gtk.glade.get_widget_tree</title>
<programlisting><methodsynopsis language="python">
<methodname>gtk.glade.get_widget_tree</methodname>
<methodparam><parameter role="keyword">widget</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">widget</parameter> :</term>
<listitem><simpara>a <link
linkend="class-gtkwidget"><classname>gtk.Widget</classname></link></simpara></listitem>
</varlistentry>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem>
<simpara>the <link
linkend="class-gladexml"><classname>gtk.glade.XML</classname></link>
object that built <parameter>widget</parameter></simpara>
</listitem>
</varlistentry>
</variablelist>
<para>This <function>gtk.glade.get_widget_tree</function>() function
is used to get the <link
linkend="class-gladexml"><classname>gtk.glade.XML</classname></link> object
that built the <link
linkend="class-gtkwidget"><classname>gtk.Widget</classname></link> specified
by <parameter>widget</parameter>.</para>
</refsect2>
<refsect2 id="function-glade--set-custom-handler">
<title>gtk.glade.set_custom_handler</title>
<programlisting><methodsynopsis language="python">
<methodname>gtk.glade.set_custom_handler</methodname>
<methodparam><parameter role="keyword">handler</parameter></methodparam>
<methodparam><parameter role="keyword">user_data</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">handler</parameter> :</term>
<listitem><simpara>the custom widget handler.</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter role="keyword">user_data</parameter> :</term>
<listitem><simpara>user data passed to the custom handler.</simpara></listitem>
</varlistentry>
</variablelist>
<para>This <function>gtk.glade.set_custom_handler</function>() function
allows you to override the default behaviour when a Custom widget is found in an interface.
</para>
</refsect2>
<refsect2 id="function-glade--bindtextdomain">
<title>gtk.glade.bindtextdomain</title>
<programlisting><methodsynopsis language="python">
<methodname>gtk.glade.bindtextdomain</methodname>
<methodparam><parameter role="keyword">domainname</parameter></methodparam>
<methodparam><parameter role="keyword">dirname</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">domainname</parameter> :</term>
<listitem><simpara>the name of the application.</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter role="keyword">dirname</parameter> :</term>
<listitem><simpara>the directory where to find locales.</simpara></listitem>
</varlistentry>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>the value of <parameter>dirname</parameter></simpara></listitem>
</varlistentry>
</variablelist>
<para>This <function>gtk.glade.bindtextdomain</function>() function allows you to use internationalisation with glade.
</para>
</refsect2>
<refsect2 id="function-glade--textdomain">
<title>gtk.glade.textdomain</title>
<programlisting><methodsynopsis language="python">
<methodname>gtk.glade.textdomain</methodname>
<methodparam><parameter role="keyword">domainname</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">domainname</parameter> :</term>
<listitem><simpara>the name of the application.</simpara></listitem>
</varlistentry>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>the value of <parameter>domainname</parameter></simpara></listitem>
</varlistentry>
</variablelist>
<para>This <function>gtk.glade.textdomain</function>() function allows you to use internationalisation with glade.
</para>
</refsect2>
<refsect2 id="function-glade--set-custom-widget-callbacks">
<title>gtk.glade.set_custom_widget_callbacks</title>
<programlisting><methodsynopsis language="python">
<methodname>gtk.glade.set_custom_widget_callbacks</methodname>
<methodparam><parameter role="keyword">dict</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">dict</parameter> :</term>
<listitem><simpara>a dictionary of function names.</simpara></listitem>
</varlistentry>
</variablelist>
<para>This <function>gtk.glade.set_custom_widget_callbacks</function>() function
takes a dictionary of function names->functions, for an example see
<ulink url="http://www.async.com.br/faq/pygtk/index.py">PyGTK FAQ 22.7</ulink>
for an example.
</para>
</refsect2>
</refsect1>
</refentry>
|