summaryrefslogtreecommitdiff
path: root/docs/reference/pygtk-gtksizegroup.xml
blob: 73ae329ff4bcbc0f7909c72fb90a83f129afb813 (plain)
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
<?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-gtksizegroup">
  <refnamediv>
    <refname>gtk.SizeGroup</refname>
    <refpurpose>an object that groups widgets so they request the same
size</refpurpose>
  </refnamediv>

  <refsect1>
    <title>Synopsis</title>

    <classsynopsis language="python">
      <ooclass><classname>gtk.SizeGroup</classname></ooclass>
      <ooclass><classname><link
linkend="class-gobject">gobject.GObject</link></classname></ooclass>
      <constructorsynopsis language="python">
	<methodname><link
linkend="constructor-gtksizegroup">gtk.SizeGroup</link></methodname>
	<methodparam><parameter
		       role="keyword">mode</parameter></methodparam>
      </constructorsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gtksizegroup--set-mode">set_mode</link></methodname>
	<methodparam><parameter
		       role="keyword">mode</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gtksizegroup--get-mode">get_mode</link></methodname>
	<methodparam></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gtksizegroup--set-ignore-hidden">set_ignore_hidden</link></methodname>
	<methodparam><parameter
		       role="keyword">ignore_hidden</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gtksizegroup--get-ignore-hidden">get_ignore_hidden</link></methodname>
	<methodparam></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gtksizegroup--add-widget">add_widget</link></methodname>
	<methodparam><parameter
		       role="keyword">widget</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gtksizegroup--remove-widget">remove_widget</link></methodname>
	<methodparam><parameter
		       role="keyword">widget</parameter></methodparam>
      </methodsynopsis>
    </classsynopsis>

  </refsect1>

  <refsect1>
    <title>Ancestry</title>

<synopsis>+-- <link linkend="class-gobject">gobject.GObject</link>
  +-- <link linkend="class-gtksizegroup">gtk.SizeGroup</link>
</synopsis>

  </refsect1>

  <refsect1 id="properties-gtksizegroup">
    <title>gtk.SizeGroup Properties</title>

    <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>"ignore-hidden"</entry>
	      <entry>Read-Write</entry>
	      <entry>If <literal>True</literal>, hidden widgets are ignored
when determining the size of the group.
Default value: <literal>False</literal>.
Available in GTK+ 2.8 and above.</entry>
	    </row>

	    <row valign="top">
	      <entry>"mode"</entry>
	      <entry>Read-Write</entry>
	      <entry>The directions in which the size group effects the
requested sizes of its component widgets - one of the <xref 
linkend="gtk-sizegroup-mode-constants" 
endterm="gtk-sizegroup-mode-constants-title"></xref>.
Default value: <literal>gtk.SIZE_GROUP_HORIZONTAL</literal>.</entry>
	    </row>

	  </tbody>
	</tgroup>
      </informaltable>
    </blockquote>

  </refsect1>

  <refsect1 id="signal-prototypes-gtksizegroup">
    <title>gtk.SizeGroup Signal Prototypes</title>

    <para><link linkend="signal-prototypes-gobject">gobject.GObject Signal Prototypes</link></para>
  </refsect1>

  <refsect1>
    <title>Description</title>

    <para><link
linkend="class-gtksizegroup"><classname>gtk.SizeGroup</classname></link>
provides a mechanism for grouping a number of widgets together so they all
request the same amount of space. This is typically useful when you want a
column of widgets to have the same size, but you can't use a <link
linkend="class-gtktable"><classname>gtk.Table</classname></link> widget. The
size requested for each widget in a <link
linkend="class-gtksizegroup"><classname>gtk.SizeGroup</classname></link> is
the maximum of the sizes that would have been requested for each widget in
the size group if they were not in the size group. The mode of the size
group (see <link
linkend="method-gtksizegroup--set-mode"><methodname>set_mode</methodname>()</link>
and the <xref linkend="gtk-sizegroup-mode-constants"
endterm="gtk-sizegroup-mode-constants-title"></xref>) determines whether
this applies to the horizontal size, the vertical size, or both
sizes:</para>

    <para>Note that size groups only affect the amount of space requested,
not the size that the widgets finally receive. If you want the widgets in a
<link
linkend="class-gtksizegroup"><classname>gtk.SizeGroup</classname></link> to
actually be the same size, you need to pack them in such a way that they get
the size they request and not more. For example, if you are packing your
widgets into a table, you would not include the <literal>gtk.FILL</literal>
flag. <link
linkend="class-gtksizegroup"><classname>gtk.SizeGroup</classname></link>
objects are referenced by each widget in the size group, so once you have
added all widgets to a <link
linkend="class-gtksizegroup"><classname>gtk.SizeGroup</classname></link>. If
the widgets in the size group are subsequently destroyed, then they will be
removed from the size group and drop their references on the size group;
when all widgets have been removed, the size group will be freed.</para>

    <para>Widgets can be part of multiple size groups; PyGTK will compute
the horizontal size of a widget from the horizontal requisition of all
widgets that can be reached from the widget by a chain of size groups of
type <literal>gtk.SIZE_GROUP_HORIZONTAL</literal> or
<literal>gtk.SIZE_GROUP_BOTH</literal>, and the vertical size from the
vertical requisition of all widgets that can be reached from the widget by a
chain of size groups of type <literal>gtk.SIZE_GROUP_VERTICAL</literal> or
<literal>gtk.SIZE_GROUP_BOTH</literal>.</para>

  </refsect1>

  <refsect1 id="constructor-gtksizegroup">
    <title>Constructor</title>

    <programlisting><constructorsynopsis language="python">
	<methodname>gtk.SizeGroup</methodname>
	<methodparam><parameter
		       role="keyword">mode</parameter></methodparam>
      </constructorsynopsis></programlisting>
    <variablelist>
      <varlistentry>
	<term><parameter role="keyword">mode</parameter>&nbsp;:</term>
	<listitem><simpara>the mode for the new size
group.</simpara></listitem>
      </varlistentry>
      <varlistentry>
	<term><emphasis>Returns</emphasis>&nbsp;:</term>
	<listitem><simpara>a new <link
linkend="class-gtksizegroup"><classname>gtk.SizeGroup</classname></link></simpara></listitem>
      </varlistentry>
    </variablelist>

    <para>Creates a new <link
linkend="class-gtksizegroup"><classname>gtk.SizeGroup</classname></link>
with the mode specified by the value of <parameter>mode</parameter> which is
one of the <xref linkend="gtk-sizegroup-mode-constants"
endterm="gtk-sizegroup-mode-constants-title"></xref>.</para>

  </refsect1>

  <refsect1>
    <title>Methods</title>

    <refsect2 id="method-gtksizegroup--set-mode">
      <title>gtk.SizeGroup.set_mode</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>set_mode</methodname>
	  <methodparam><parameter
			 role="keyword">mode</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">mode</parameter>&nbsp;:</term>
	  <listitem><simpara>the mode to set for the size
group.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>set_mode</methodname>() method sets the "mode"
property of the size group to the value specified by
<parameter>mode</parameter>. The "mode" of the size group determines whether
the widgets in the size group should all have the same horizontal
requisition (see the <xref linkend="gtk-sizegroup-mode-constants"
endterm="gtk-sizegroup-mode-constants-title"></xref>).</para>

    </refsect2>

    <refsect2 id="method-gtksizegroup--get-mode">
      <title>gtk.SizeGroup.get_mode</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_mode</methodname>
	  <methodparam></methodparam>
        </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>the current mode of the size
group.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>get_mode</methodname>() method returns the value
of the "mode" property of the size group. See the <link
linkend="method-gtksizegroup--set-mode"><methodname>set_mode</methodname>()</link> 
method.</para>

    </refsect2>

    <refsect2 id="method-gtksizegroup--set-ignore-hidden">
      <title>gtk.SizeGroup.set_ignore_hidden</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>set_ignore_hidden</methodname>
	  <methodparam><parameter
			 role="keyword">ignore_hidden</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">ignore_hidden</parameter>&nbsp;:</term>
	  <listitem><simpara>If <literal>True</literal> hidden widgets should
be ignored when calculating the size</simpara></listitem>
	</varlistentry>
      </variablelist>

      <note>
        <para>This method is available in PyGTK 2.8 and above.</para>
      </note>

      <para>The <methodname>set_ignore_hidden</methodname>() method sets the
"ignore-hidden" property to the value of
<parameter>ignore_hidden</parameter>. If
<parameter>ignore_hidden</parameter> is <literal>True</literal> invisible
widgets will be ignored when calculating size.</para>

    </refsect2>

    <refsect2 id="method-gtksizegroup--get-ignore-hidden">
      <title>gtk.SizeGroup.get_ignore_hidden</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_ignore_hidden</methodname>
	  <methodparam></methodparam>
        </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara><literal>True</literal> if hidden widgets are
ignored in size calculations.</simpara></listitem>
	</varlistentry>
      </variablelist>

       <note>
        <para>This method is available in PyGTK 2.8 and above.</para>
      </note>

      <para>The <methodname>get_ignore_hidden</methodname>() method returns
the value of the "ignore-hidden" property of the size group. If
"ignore-hidden" is <literal>True</literal>, invisible widgets are ignored in
size calculations.</para>

    </refsect2>

    <refsect2 id="method-gtksizegroup--add-widget">
      <title>gtk.SizeGroup.add_widget</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>add_widget</methodname>
	  <methodparam><parameter
			 role="keyword">widget</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">widget</parameter>&nbsp;:</term>
	  <listitem><simpara>the <link
linkend="class-gtkwidget"><classname>gtk.Widget</classname></link> to
add</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>add_widget</methodname>() method adds the widget
specified by <parameter>widget</parameter> to the <link
linkend="class-gtksizegroup"><classname>gtk.SizeGroup</classname></link>.
The requisition of the widget will then be determined as the maximum of its
requisition and the requisition of the other widgets in the size group.
Whether this applies horizontally, vertically, or in both directions depends
on the mode of the size group. See the <link
linkend="method-gtksizegroup--set-mode"><methodname>set_mode</methodname>()</link> 
method for more detail.</para>

    </refsect2>

    <refsect2 id="method-gtksizegroup--remove-widget">
      <title>gtk.SizeGroup.remove_widget</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>remove_widget</methodname>
	  <methodparam><parameter
			 role="keyword">widget</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">widget</parameter>&nbsp;:</term>
	  <listitem><simpara>the <link
linkend="class-gtkwidget"><classname>gtk.Widget</classname></link> to
remove</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The remove_widget() method removes the widget specified by
widget from the <link
linkend="class-gtksizegroup"><classname>gtk.SizeGroup</classname></link>.</para>

    </refsect2>

  </refsect1>

</refentry>