summaryrefslogtreecommitdiff
path: root/docs/reference/pygtk-gtkcomboboxentry.xml
blob: cfc304252eeada320aef0880302304a51de4083a (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
350
351
352
353
354
355
<?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-gtkcomboboxentry">
  <refnamediv>
    <refname>gtk.ComboBoxEntry</refname> <refpurpose>a text entry field with
    a dropdown list (new in PyGTK 2.4)</refpurpose>
  </refnamediv>

  <refsect1>
    <title>Synopsis</title>

    <classsynopsis language="python">
      <ooclass><classname>gtk.ComboBoxEntry</classname></ooclass>
      <ooclass><classname><link linkend="class-gtkcombobox">gtk.ComboBox</link></classname></ooclass>
      <ooclass><classname><link linkend="class-gtkcelllayout">gtk.CellLayout</link></classname></ooclass>
      <constructorsynopsis language="python">
	<methodname><link linkend="constructor-gtkcomboboxentry">gtk.ComboBoxEntry</link></methodname>
	<methodparam><parameter role="keyword">model</parameter><initializer>None</initializer></methodparam>
	<methodparam><parameter role="keyword">column</parameter><initializer>-1</initializer></methodparam>
      </constructorsynopsis>
      <methodsynopsis language="python">
	<methodname><link linkend="method-gtkcomboboxentry--set-text-column">set_text_column</link></methodname>
	<methodparam><parameter role="keyword">text_column</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link linkend="method-gtkcomboboxentry--get-text-column">get_text_column</link></methodname>
	<methodparam></methodparam>
      </methodsynopsis>
    </classsynopsis>

    <programlisting>
<emphasis role="bold">Functions</emphasis>

<methodsynopsis language="python">
	<methodname><link linkend="function-gtk--combo-box-entry-new-text">gtk.combo_box_entry_new_text</link></methodname>
	<methodparam></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-gtkcombobox">gtk.ComboBox</link>
            +-- <link linkend="class-gtkcomboboxentry">gtk.ComboBoxEntry</link>
</synopsis>

  </refsect1>
  
  <refsect1>
		<title>Implemented Interfaces</title>
		<para>
			<link linkend="class-gtkcomboboxentry"><classname>gtk.ComboBoxEntry</classname></link>
			implements 
			<link linkend="class-gtkbuildable"><classname>gtk.Buildable</classname></link>
            <link linkend="class-gtkcelllayout"><classname>gtk.CellLayout</classname></link>
		</para>
	</refsect1>


  <refsect1 id="properties-gtkcomboboxentry">
    <title>gtk.ComboBoxEntry 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-gtkcombobox">gtk.ComboBox 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>"text-column"</entry>
	      <entry>Read-Write</entry>
	      <entry>The column in the <link
	      linkend="class-gtktreemodel"><classname>gtk.TreeModel</classname></link>
	      to get the strings from.</entry>
	    </row>

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

  </refsect1>

  <refsect1 id="style-properties-gtkcomboboxentry">
    <title>gtk.ComboBoxEntry Style Properties</title>

    <para><link linkend="style-properties-gtkwidget">gtk.Widget Style Properties</link></para>
    <para><link linkend="style-properties-gtkcombobox">gtk.ComboBox Style Properties</link></para>

  </refsect1>

  <refsect1 id="signal-prototypes-gtkcomboboxentry">
    <title>gtk.ComboBoxEntry 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-gtkcombobox">gtk.ComboBox Signal Prototypes</link></para>
    <para><link linkend="signal-prototypes-gtkcelleditable">gtk.CellEditable Signal Prototypes</link></para>
  </refsect1>

  <refsect1>
    <title>Description</title>

    <note>
      <para>This widget is available in GTK+ 2.4 and PyGTK 2.4 and
      above.</para> </note>
 
    <para>The <link
linkend="class-gtkcomboboxentry"><classname>gtk.ComboBoxEntry</classname></link>
is a replacement for the <link
linkend="class-gtkcombo"><classname>gtk.Combo</classname></link>. The <link
linkend="class-gtkcomboboxentry"><classname>gtk.ComboBoxEntry</classname></link>
is subclassed from <link
linkend="class-gtkcombobox"><classname>gtk.ComboBox</classname></link> and
implements the <link
linkend="class-gtkcelllayout"><classname>gtk.CellLayout</classname></link>
interface; refer to their descriptions for a number of useful methods and
properties for managing the contents of a combo box entry. A <link
linkend="class-gtkcomboboxentry"><classname>gtk.ComboBoxEntry</classname></link>
also contains a child <link
linkend="class-gtkentry"><classname>gtk.Entry</classname></link> accessed by
using the child attribute of the combo box entry:</para>

    <programlisting>
  entry = comboboxentry.child
</programlisting>

    <para>A <link
linkend="class-gtkcomboboxentry"><classname>gtk.ComboBoxEntry</classname></link>
is created with the <link
linkend="constructor-gtkcomboboxentry">gtk.ComboBoxEntry()</link>
constructor. The constructor can also be called with the optional parameters
<parameter>model</parameter> (a <link
linkend="class-gtktreemodel"><classname>gtk.TreeModel</classname></link> -
default <literal>None</literal>) and <parameter>column</parameter> (a number
of a column in <parameter>model</parameter> - default 0). If no <link
linkend="class-gtktreemodel"><classname>gtk.TreeModel</classname></link> is
specified it can be added later with the <link
linkend="method-gtkcombobox--set-model"><methodname>set_model</methodname>()</link>
method. The text column can be changed using the <link
linkend="method-gtkcomboboxentry--set-text-column"><methodname>set_text_column</methodname>()</link>
method. A new combo box entry is created and packed with a <link
linkend="class-gtkcellrenderertext"><classname>gtk.CellRendererText</classname></link>
but no attribute mappings are set on the cell renderer.</para>
 
    <para>Alternatively, the <link
linkend="function-gtk--combo-box-entry-new-text"><function>gtk.combo_box_entry_new_text</function>()</link>
function creates a <link
linkend="class-gtkcomboboxentry"><classname>gtk.ComboBoxEntry</classname></link>
with an associated <link
linkend="class-gtkliststore"><classname>gtk.ListStore</classname></link>
model and the text column attribute mapping set to 0. In this combo box
entry each list item is a text string that can be selected.  The convenience
methods <link
linkend="method-gtkcombobox--append-text"><methodname>gtk.ComboBox.append_text</methodname>()</link>,
<link
linkend="method-gtkcombobox--prepend-text"><methodname>gtk.ComboBox.prepend_text</methodname>()</link>,
<link
linkend="method-gtkcombobox--insert-text"><methodname>gtk.ComboBox.insert_text</methodname>()</link>
and <link
linkend="method-gtkcombobox--remove-text"><methodname>gtk.ComboBox.remove_text</methodname>()</link>
can be used to manage the contents of the <link
linkend="class-gtkcomboboxentry"><classname>gtk.ComboBoxEntry</classname></link>. Using
the <link
linkend="function-gtk--combo-box-entry-new-text"><function>gtk.combo_box_entry_new_text</function>()</link>
function is equivalent to:</para>
                                                                                
    <programlisting>
  liststore = gtk.ListStore(gobject.TYPE_STRING)
  comboboxentry = gtk.ComboBoxEntry(liststore, 0)
</programlisting>

  </refsect1>

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

    <programlisting><constructorsynopsis language="python">
	<methodname>gtk.ComboBoxEntry</methodname>
	<methodparam><parameter role="keyword">model</parameter><initializer>None</initializer></methodparam>
	<methodparam><parameter role="keyword">column</parameter><initializer>-1</initializer></methodparam>
      </constructorsynopsis></programlisting>
    <variablelist>
      <varlistentry>
	<term><parameter role="keyword">model</parameter>&nbsp;:</term>
	<listitem><simpara>The <link
	linkend="class-gtktreemodel"><classname>gtk.TreeModel</classname></link>
	to associate with the combo box entry, or
	<literal>None</literal></simpara></listitem>
      </varlistentry>
      <varlistentry>
	<term><parameter role="keyword">column</parameter>&nbsp;:</term>
	<listitem><simpara>The number of the column to use for setting the
	strings of the combo box entry.</simpara></listitem>
      </varlistentry>
      <varlistentry>
	<term><emphasis>Returns</emphasis>&nbsp;:</term>
	<listitem><simpara>A new <link
	linkend="class-gtkcomboboxentry"><classname>gtk.ComboBoxEntry</classname></link>.</simpara></listitem>
      </varlistentry>
    </variablelist>

    <note>
      <para>This constructor is available in PyGTK 2.4 and above.</para>
    </note>

    <para>Creates a new <link
linkend="class-gtkcomboboxentry"><classname>gtk.ComboBoxEntry</classname></link>
that has a <link
linkend="class-gtkentry"><classname>gtk.Entry</classname></link> as child
and associated with the <link
linkend="class-gtktreemodel"><classname>gtk.TreeModel</classname></link>
specified by <parameter>model</parameter> and using the column of
<parameter>model</parameter> specified by <parameter>column</parameter> to
retrieve strings. If <parameter>model</parameter> was not specified it
defaults to <literal>None</literal> but you can change the model using the
<link
linkend="method-gtkcombobox--set-model"><methodname>gtk.ComboBox.set_model()</methodname></link>
method. If <parameter>column</parameter> was not specified it defaults to -1
meaning the text column is unset but you can change it using the <link
linkend="method-gtkcomboboxentry--set-text-column"><methodname>set_text_column</methodname>()</link>
method. Once the text column is set either in the constructor or using the
<link
linkend="method-gtkcomboboxentry--set-text-column"><methodname>set_text_column</methodname>()</link>
method it cannot be changed. A ValueError exception is thrown if
<parameter>column</parameter> is outside the range of column numbers for
<parameter>model</parameter>.</para>

  </refsect1>

  <refsect1>
    <title>Methods</title>

    <refsect2 id="method-gtkcomboboxentry--set-text-column">
      <title>gtk.ComboBoxEntry.set_text_column</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>set_text_column</methodname>
	  <methodparam><parameter role="keyword">text_column</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter
	  role="keyword">text_column</parameter>&nbsp;:</term>
	  <listitem><simpara>A column in the associated <link
	  linkend="class-gtktreemodel"><classname>gtk.TreeModel</classname></link>
	  to use as the data source for the strings.</simpara></listitem>
	</varlistentry>
      </variablelist>

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

      <para>The <methodname>set_text_column</methodname>() method sets the
"text-column" property to the value of <parameter>tree_column</parameter>
only if the text column has not been set (that is, "text-column" is -1). The
value of <parameter>tree_column</parameter> is the number of the tree model
column used as the data source for the strings of the combo box
entry.</para>

    </refsect2>

    <refsect2 id="method-gtkcomboboxentry--get-text-column">
      <title>gtk.ComboBoxEntry.get_text_column</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_text_column</methodname>
	  <methodparam></methodparam>  </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>The number of the column in the associated
	  <link
	  linkend="class-gtktreemodel"><classname>gtk.TreeModel</classname></link>
	  used as the data source for the combo box
	  entry.</simpara></listitem>
	</varlistentry>
      </variablelist>

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

      <para>The <methodname>get_text_column</methodname>() method returns
the number of the <link
linkend="class-gtktreemodel"><classname>gtk.TreeModel</classname></link>
column that is used as the data source for the strings of the combo box
entry.</para>

    </refsect2>

  </refsect1>

  <refsect1>
    <title>Functions</title>

    <refsect2 id="function-gtk--combo-box-entry-new-text">
      <title>gtk.combo_box_entry_new_text</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>gtk.combo_box_entry_new_text</methodname>
	  <methodparam></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	<term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>A new <link
	  linkend="class-gtkcomboboxentry"><classname>gtk.ComboBoxEntry</classname></link>
	  widget.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <note>
	<para>This function is available in PyGTK 2.4 and above.</para>
      </note>

      <para>The <function>gtk.combo_box_entry_new_text</function>() function
is a convenience function which constructs a new <link
linkend="class-gtkcomboboxentry"><classname>gtk.ComboBoxEntry</classname></link>,
just displaying strings. If you use this function to create a combo box
entry, you should only manipulate its <link
linkend="class-gtktreemodel"><classname>gtk.TreeModel</classname></link>
data source with the following <link
linkend="class-gtkcombobox"><classname>gtk.ComboBox</classname></link>
convenience methods: <link
linkend="method-gtkcombobox--append-text"><methodname>gtk.ComboBox.append_text</methodname>()</link>,
<link
linkend="method-gtkcombobox--insert-text"><methodname>gtk.ComboBox.insert_text</methodname>()</link>,
<link
linkend="method-gtkcombobox--prepend-text"><methodname>gtk.ComboBox.prepend_text</methodname>()</link>
and <link
linkend="method-gtkcombobox--remove-text"><methodname>gtk.ComboBox.remove_text</methodname>()</link>.</para>

    </refsect2>

  </refsect1>

</refentry>