summaryrefslogtreecommitdiff
path: root/docs/reference/pygtk-gtkfilechooserbutton.xml
blob: 69cf3874585ed6a1630baa785e8e7f70e7da7c89 (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
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
<?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-gtkfilechooserbutton">
  <refnamediv>
    <refname>gtk.FileChooserButton</refname>
    <refpurpose>a button to launch a <link
linkend="class-gtkfilechooserdialog"><classname>gtk.FileChooserDialog</classname></link>
(new in PyGTK 2.6)</refpurpose>
  </refnamediv>

  <refsect1>
    <title>Synopsis</title>

<classsynopsis language="python">
  <ooclass><classname>gtk.FileChooserButton</classname></ooclass>
  <ooclass><classname><link linkend="class-gtkhbox">gtk.HBox</link></classname></ooclass>
<constructorsynopsis language="python">
    <methodname><link linkend="constructor-gtkfilechooserbutton">gtk.FileChooserButton</link></methodname>
    <methodparam><parameter role="keyword">title</parameter></methodparam>
    <methodparam><parameter role="keyword">backend</parameter><initializer>None</initializer></methodparam>
  </constructorsynopsis>
<constructorsynopsis language="python">
    <methodname><link linkend="constructor-gtkfilechooserbutton2">gtk.FileChooserButton</link></methodname>
    <methodparam><parameter role="keyword">dialog</parameter></methodparam>
  </constructorsynopsis>
<methodsynopsis language="python">
    <methodname><link linkend="method-gtkfilechooserbutton--get-title">get_title</link></methodname>
    <methodparam><parameter role="keyword"></parameter></methodparam>
  </methodsynopsis>
<methodsynopsis language="python">
    <methodname><link linkend="method-gtkfilechooserbutton--set-title">set_title</link></methodname>
    <methodparam><parameter role="keyword">title</parameter></methodparam>
  </methodsynopsis>
<methodsynopsis language="python">
    <methodname><link linkend="method-gtkfilechooserbutton--get-width-chars">get_width_chars</link></methodname>
    <methodparam><parameter role="keyword"></parameter></methodparam>
  </methodsynopsis>
<methodsynopsis language="python">
    <methodname><link linkend="method-gtkfilechooserbutton--set-width-chars">set_width_chars</link></methodname>
    <methodparam><parameter role="keyword">n_chars</parameter></methodparam>
  </methodsynopsis>
      <methodsynopsis language="python">
        <methodname><link linkend="method-gtkfilechooserbutton--get-focus-on-click">get_focus_on_click</link></methodname>
        <methodparam></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
        <methodname><link linkend="method-gtkfilechooserbutton--set-focus-on-click">set_focus_on_click</link></methodname>
        <methodparam><parameter role="keyword">focus_on_click</parameter></methodparam>
      </methodsynopsis>
</classsynopsis>

</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-gtkbox">gtk.Box</link>
           +-- <link linkend="class-gtkhbox">gtk.HBox</link>
             +-- <link linkend="class-gtkfilechooserbutton">gtk.FileChooserButton</link> (implements <link linkend="class-gtkfilechooser">gtk.FileChooser</link>)</synopsis>

  </refsect1>
  
  <refsect1>
		<title>Implemented Interfaces</title>
		<para>
			<link linkend="class-gtkfilechooserbutton"><classname>gtk.FileChooserButton</classname></link>
			implements 
			<link linkend="class-gtkbuildable"><classname>gtk.Buildable</classname></link>
		</para>
	</refsect1>

  <refsect1 id="properties-gtkfilechooserbutton">
    <title>gtk.FileChooserButton Properties</title>

    <para><link linkend="properties-gtkfilechooser">gtk.FileChooser Properties</link></para>
    <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-gtkbox">gtk.Box 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>"dialog"</entry>
	      <entry>Write-Construct Only</entry>

	      <entry>The <link
	      linkend="class-gtkfilechooserdialog"><classname>gtk.FileChooserDialog</classname></link>
	      associated with the button. Available in GTK+ 2.6.</entry>
	    </row>

	    <row valign="top">
	      <entry>"focus-on-click"</entry>
	      <entry>Read-Write</entry>

	      <entry>If <literal>True</literal> the <link
	      linkend="class-gtkfilechooserbutton"><classname>gtk.FileChooserButton</classname></link>
	      button grabs focus when it is clicked with the mouse. Default
	      value: <literal>True</literal>. Available in GTK+
	      2.10.</entry>
	    </row>

	    <row valign="top">
	      <entry>"title"</entry>
	      <entry>Read-Write</entry>

	      <entry>The string to use as the title on the <link
	      linkend="class-gtkfilechooserdialog"><classname>gtk.FileChooserDialog</classname></link>
	      associated with the button. Default value: "Select A
	      File". Available in GTK+ 2.6.</entry>
	    </row>

	    <row valign="top">
	      <entry>"width-chars"</entry>
	      <entry>Read-Write</entry>

	      <entry>The width of the entry and label inside the button, in
	      characters. Allowed values: >= -1. Default value:
	      -1. Available in GTK+ 2.6.</entry>
	    </row>

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

  </refsect1>

  <refsect1 id="style-properties-gtkfilechooserbutton">
    <title>gtk.FileChooserButton Style Properties</title>

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

  </refsect1>

  <refsect1 id="child-properties-gtkfilechooserbutton">
    <title>gtk.FileChooserButton Child Properties</title>

    <para><link linkend="child-properties-gtkbox">gtk.Box Child Properties</link></para>

  </refsect1>

  <refsect1 id="signal-prototypes-gtkfilechooserbutton">
    <title>gtk.FileChooserButton 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-gtkfilechooser">gtk.FileChooser Signal Prototypes</link></para>
    
    <variablelist>
      <varlistentry>
        <term>"<link linkend="signal-gtkfilechooserbutton--file-set">file-set</link>"</term>
        <listitem>
          <methodsynopsis language="python"><methodname>callback</methodname>
            <methodparam><parameter>filechooserbutton</parameter>
            </methodparam>
            <methodparam><parameter>user_param1</parameter>
            </methodparam>
            <methodparam><parameter>...</parameter>
            </methodparam>
          </methodsynopsis>
        </listitem>
      </varlistentry>
    </variablelist>
  </refsect1>

  <refsect1>
    <title>Description</title>

    <note>
      <para>This widget is available in PyGTK 2.6 and above.</para>
    </note>

    <para>The <link
    linkend="class-gtkfilechooserbutton"><classname>gtk.FileChooserButton</classname></link>
    is a widget that lets the user select a file. It implements the <link
    linkend="class-gtkfilechooser"><classname>gtk.FileChooser</classname></link>
    interface. Visually, it is a file name with a button to bring up a <link
    linkend="class-gtkfilechooserdialog"><classname>gtk.FileChooserDialog</classname></link>. The
    user can then use that dialog to change the file associated with that
    button. This widget does not support setting the "select-multiple"
    property to <literal>True</literal>. For example to create a <link
    linkend="class-gtkfilechooserbutton"><classname>gtk.FileChooserButton</classname></link>
    and set the current folder to '/etc' use:</para>

    <programlisting>
  filechooserbutton = gtk.FileChooserButton('Select a File')
  filechooserbutton.set_current_folder('/etc')
</programlisting>

    <para>The <link
    linkend="class-gtkfilechooserbutton"><classname>gtk.FileChooserButton</classname></link>
    supports the <literal>gtk.FILE_CHOOSER_ACTION_OPEN</literal> and
    <literal>gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER</literal> actions of the
    <xref linkend="gtk-filechooser-action-constants"
    endterm="gtk-filechooser-action-constants-title"></xref>.</para>

    <note>
      <para>The <link
      linkend="class-gtkfilechooserbutton"><classname>gtk.FileChooserButton</classname></link>
      will ellipsize the label, and thus will thus request little horizontal
      space. To give the button more space, you should call the <link
      linkend="method-gtkwidget--size-request"><methodname>gtk.Widget.size_request</methodname>()</link>
      method, the <link
      linkend="method-gtkfilechooserbutton--set-width-chars"><methodname>set_width_chars</methodname>()</link>
      method, or pack the button in such a way that other interface elements
      give space to the widget.</para>
    </note>

  </refsect1>

  <refsect1>
    <title>Constructor</title>

    <refsect2 id="constructor-gtkfilechooserbutton">
      <title>gtk.FileChooserButton</title>

      <programlisting><constructorsynopsis language="python">
          <methodname>gtk.FileChooserButton</methodname>
          <methodparam><parameter
                         role="keyword">title</parameter></methodparam>
          <methodparam><parameter
                         role="keyword">backend</parameter><initializer>None</initializer></methodparam>
        </constructorsynopsis></programlisting>
      <variablelist>
        <varlistentry>
          <term><parameter role="keyword">title</parameter>&nbsp;:</term>
          <listitem><simpara>the title of the browse dialog</simpara></listitem>
        </varlistentry>
        <varlistentry>
          <term><parameter role="keyword">backend</parameter>&nbsp;:</term>
          <listitem><simpara>the name of a file system backend or
<literal>None</literal></simpara></listitem>
        </varlistentry>
        <varlistentry>
          <term><emphasis>Returns</emphasis>&nbsp;:</term>
          <listitem><simpara>a new <link
linkend="class-gtkfilechooserbutton"><classname>gtk.FileChooserButton</classname></link></simpara></listitem>
        </varlistentry>
      </variablelist>

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

      <para>Creates a new button widget that opens a <link
linkend="class-gtkfilechooserdialog"><classname>gtk.FileChooserDialog</classname></link>
when clicked. The title of the <link
linkend="class-gtkfilechooserdialog"><classname>gtk.FileChooserDialog</classname></link>
is specified by <parameter>title</parameter>. If
<parameter>backend</parameter> is specified it is the name of a file system
backend.</para>

    </refsect2>

    <refsect2 id="constructor-gtkfilechooserbutton2">
      <title>gtk.FileChooserButton</title>

      <programlisting><constructorsynopsis language="python">
          <methodname>gtk.FileChooserButton</methodname>
          <methodparam><parameter
                         role="keyword">dialog</parameter></methodparam>
        </constructorsynopsis></programlisting>
      <variablelist>
        <varlistentry>
          <term><parameter role="keyword">dialog</parameter>&nbsp;:</term>
          <listitem><simpara>a <link linkend="class-gtkfilechooserdialog"><classname>gtk.FileChooserDialog</classname></link></simpara></listitem>
        </varlistentry>
        <varlistentry>
          <term><emphasis>Returns</emphasis>&nbsp;:</term>
          <listitem><simpara>a new <link
linkend="class-gtkfilechooserbutton"><classname>gtk.FileChooserButton</classname></link></simpara></listitem>
        </varlistentry>
      </variablelist>

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

      <para>Creates a new button widget that opens a <link
linkend="class-gtkfilechooserdialog"><classname>gtk.FileChooserDialog</classname></link>
specified by <parameter>dialog</parameter> when clicked.</para>

    </refsect2>

  </refsect1>

  <refsect1>
    <title>Methods</title>

    <refsect2 id="method-gtkfilechooserbutton--get-title">
      <title>gtk.FileChooserButton.get_title</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_title</methodname>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	<term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>the title of the <link
linkend="class-gtkfilechooserdialog"><classname>gtk.FileChooserDialog</classname></link></simpara></listitem>
	</varlistentry>
      </variablelist>

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

      <para>The <methodname>get_title</methodname>() method returns the
value of the "title" property which contains the title of the associated
<link
linkend="class-gtkfilechooserdialog"><classname>gtk.FileChooserDialog</classname></link>.</para>

    </refsect2>

    <refsect2 id="method-gtkfilechooserbutton--set-title">
      <title>gtk.FileChooserButton.set_title</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>set_title</methodname>
	  <methodparam><parameter
			 role="keyword">title</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">title</parameter>&nbsp;:</term>
	  <listitem><simpara>a string to use as the title of the associated 
<link
linkend="class-gtkfilechooserdialog"><classname>gtk.FileChooserDialog</classname></link>.</simpara></listitem>
	</varlistentry>
      </variablelist>

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

      <para>The <methodname>set_title</methodname>() method sets the "title"
property to the value of <parameter>title</parameter>. The "title" property
contains the title string of the associated <link
linkend="class-gtkfilechooserdialog"><classname>gtk.FileChooserDialog</classname></link>.</para>

    </refsect2>

    <refsect2 id="method-gtkfilechooserbutton--get-width-chars">
      <title>gtk.FileChooserButton.get_width_chars</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_width_chars</methodname>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	<term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <term><parameter
role="keyword"></parameter>&nbsp;:</term>
	  <listitem><simpara>the width in characters of the
button</simpara></listitem>
	</varlistentry>
      </variablelist>

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

      <para>The <methodname>get_width_chars</methodname>() method returns
the value of the "width-characters" property which contains the number of
characters the button width should be set to.</para>

    </refsect2>

    <refsect2 id="method-gtkfilechooserbutton--set-width-chars">
      <title>gtk.FileChooserButton.set_width_chars</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>set_width_chars</methodname>
	  <methodparam><parameter
			 role="keyword">n_chars</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">n_chars</parameter>&nbsp;:</term>
	  <listitem><simpara>the width in characters for the
button</simpara></listitem>
	</varlistentry>
      </variablelist>

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

      <para>The <methodname>set_width_chars</methodname>() method sets the
"width-chars" property to the value of <parameter>n_chars</parameter>. The
"width-chars" property contains the width in characters that the button
should be set to.</para>

    </refsect2>

    <refsect2 id="method-gtkfilechooserbutton--get-focus-on-click">
      <title>gtk.FileChooserButton.get_focus_on_click</title>

      <programlisting><methodsynopsis language="python">
        <methodname>get_focus_on_click</methodname>
        <methodparam></methodparam>
      </methodsynopsis></programlisting>

      <variablelist>
        <varlistentry>
          <term><emphasis>Returns</emphasis>&nbsp;:</term>
          <listitem><simpara><literal>True</literal> if the button grabs
          focus when it is clicked with the mouse.</simpara></listitem>
        </varlistentry>
      </variablelist>

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

      <para>The <methodname>get_focus_on_click</methodname>() method returns
      the value of the "focus-on-click" property. If the return value is
      <literal>True</literal> if the button grabs focus when it is clicked
      with the mouse.  See the <link
      linkend="method-gtkfilechooserbutton--set-focus-on-click"><methodname>set_focus_on_click()</methodname></link>
      method.</para>

    </refsect2>

    <refsect2 id="method-gtkfilechooserbutton--set-focus-on-click">
      <title>gtk.FileChooserButton.set_focus_on_click</title>

      <programlisting><methodsynopsis language="python">
        <methodname>set_focus_on_click</methodname>
        <methodparam><parameter role="keyword">focus_on_click</parameter></methodparam>
      </methodsynopsis></programlisting>

      <variablelist>
        <varlistentry>
          <term><parameter role="keyword">focus_on_click</parameter>&nbsp;:</term>
          <listitem><simpara>If <literal>True</literal>, the button grabs
          focus when clicked with the mouse</simpara></listitem>
        </varlistentry>
      </variablelist>

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

      <para>The <methodname>set_focus_on_click</methodname>() method sets
      the "focus-on-click" property to the value of
      <parameter>focus_on_click</parameter>.  If
      <parameter>focus_on_click</parameter> is <literal>True</literal>, the
      button will grab focus when it is clicked with the mouse.  Making
      mouse clicks not grab focus is useful in places like toolbars where
      you don't want the keyboard focus removed from the main area of the
      application.</para>

    </refsect2>

  </refsect1><refsect1>
    <title>Signals</title>

    <refsect2 id="signal-gtkfilechooserbutton--file-set">
      <title>The "file-set" gtk.FileChooserButton Signal</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>callback</methodname>
	  <methodparam><parameter>filechooserbutton</parameter></methodparam>
	  <methodparam><parameter>user_param1</parameter></methodparam>
	  <methodparam><parameter>...</parameter></methodparam>
	</methodsynopsis></programlisting>

      <variablelist>
	<varlistentry>
	  <term><parameter>filechooserbutton</parameter>&nbsp;:</term>
	  <listitem><simpara>the filechooserbutton that received the signal</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter>user_param1</parameter>&nbsp;:</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>&nbsp;:</term>
	  <listitem><simpara>additional user parameters (if any)</simpara></listitem>
	</varlistentry>
      </variablelist>

      <note>
	<para>This signal is available in GTK+ 2.12 and above.</para>
      </note>

      <para>
	  The "file-set" signal is emitted when the user selects a file. 
      </para>
      <para>
	  Note that this signal is only emitted when the user changes the file.
      </para>

    </refsect2>
  </refsect1>

</refentry>