File: ch-GtkRcFiles.html

package info (click to toggle)
python-gtk2-tutorial 2.3-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,376 kB
  • ctags: 918
  • sloc: python: 5,731; makefile: 36
file content (33 lines) | stat: -rw-r--r-- 5,035 bytes parent folder | download | duplicates (2)
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
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter23.GTK's rc Files</title><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="index.html" title="PyGTK 2.0 Tutorial"><link rel="up" href="index.html" title="PyGTK 2.0 Tutorial"><link rel="previous" href="sec-DNDMethods.html" title="22.3.DND Methods"><link rel="next" href="sec-GTKRcFileFormat.html" title="23.2.GTK's rc File Format"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter23.GTK's rc Files</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="sec-DNDMethods.html">Prev</a></td><th width="60%" align="center"></th><td width="20%" align="right"><a accesskey="n" href="sec-GTKRcFileFormat.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="ch-GtkRcFiles"></a>Chapter23.GTK's rc Files</h2></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="ch-GtkRcFiles.html#sec-FunctionsForRcFiles">23.1. Functions For rc Files</a></span></dt><dt><span class="sect1"><a href="sec-GTKRcFileFormat.html">23.2. GTK's rc File Format</a></span></dt><dt><span class="sect1"><a href="sec-ExampleRcFile.html">23.3. Example rc file</a></span></dt></dl></div><p>GTK+ has its own way of dealing with application defaults, by
using rc files. These can be used to set the colors of just about any
widget, and can also be used to tile pixmaps onto the background of some
widgets.</p><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec-FunctionsForRcFiles"></a>23.1.Functions For rc Files</h2></div></div><div></div></div><p>When your application starts, you should include a call
to:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  rc_parse(<b class="parameter"><tt>filename</tt></b>)
</pre></td></tr></table><p>Passing in the <i class="parameter"><tt>filename</tt></i> of your rc file. This
will cause GTK+ to parse this file, and use the style settings for the widget
types defined there.</p><p>If you wish to have a special set of widgets that can take on a
different style from others, or any other logical division of widgets, use a
call to:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  widget.set_name(<b class="parameter"><tt>name</tt></b>)
</pre></td></tr></table><p>Your newly created <i class="parameter"><tt>widget</tt></i> will be assigned
the <i class="parameter"><tt>name</tt></i> you give. This will allow you to change the
attributes of this <i class="parameter"><tt>widget</tt></i> by name through the rc
file.</p><p>If we use a call something like this:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  button = gtk.Button("Special Button")

  button.set_name("special button")
</pre></td></tr></table><p>Then this <i class="parameter"><tt>button</tt></i> is given the name "special
button" and may be addressed by name in the rc file as "special
button.GtkButton". [--- Verify ME!]</p><p><a href="sec-ExampleRcFile.html" title="23.3.Example rc file">Section23.3, &#8220;Example rc file&#8221;</a> below, sets the
properties of the main window, and lets all children of that main window
inherit the style described by the "main button" style. The code used in the
application is:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  window = gtk.Window(gtk.WINDOW_TOPLEVEL)

  window.set_name("main window")
</pre></td></tr></table><p>And then the style is defined in the rc file using:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  widget "main window.*GtkButton*" style "main_button"
</pre></td></tr></table><p>Which sets all the <tt class="classname">Button</tt> (see <a href="ch-ButtonWidget.html" title="Chapter6.The Button Widget">Chapter6, <i>The Button Widget</i></a> widgets in the "main window" to the
"main_buttons" style as defined in the rc file.</p><p>As you can see, this is a fairly powerful and flexible system.
Use your imagination as to how best to take advantage of this.</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sec-DNDMethods.html">Prev</a></td><td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td><td width="40%" align="right"><a accesskey="n" href="sec-GTKRcFileFormat.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">22.3.DND Methods</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">23.2.GTK's rc File Format</td></tr></table></div></body></html>