A standard dialogue to choose a file.
Synopsis
gnocl::fileChooserDialog [-option
value...]
Screenshot
Options
- -action one
of open, save, openFolder, createFolder, selectFolder (default:
open)
- Action to perform.
- -currentName string
(default: "")
- Current name in the file
selector, as if entered by the user. This should be used for
example in a "Save as" dialogue to suggest a name.
- -currentFolder string
(default: "")
- Current folder.
- -createFolders boolean
(default: 0)
- TO BE COMPLETED
- -extraWidget string
(default: "")
- ID of a Gnocl widget, for extra
options.
- -fileFilters string
(default: "")
- List of file filter objects to
be displayed within the dialog filter pull-down menu. The list
comprise pairs of sequence of filter names and filetypes.
- -filename string
(default: "")
- Current filename.
- -getURIs boolean
(default: 0)
- Whether to return URIs instead
of file names. (This is not yet tested.)
- -localOnly boolean
- Whether only local files can be
chosen.
- -name string
- Name of the widget, can be used
to set options in an rc file.
- -onDestroy string
(default: "")
- Tcl command which is executed if
the widget is destroyed. Before evaluation the following percent
strings are substituted:
%w widget name - -onUpdatePreview string
(default: "")
- Tcl command to be executed, if
the preview widget has to be updated. Before evaluation the
following percent strings are substituted:
%w widget name
- -onConfirmOverwrite string
(default: "")
- Tcl command executed when an overwrite comfirmation dialog is presented. Before evaluation the
following percent strings are substituted:
%f URI of the selected file.
- -onFileActivated string
(default: "")
- TO BE COMPLETED.
- -onFolderChanged string
(default: "")
- TO BE COMPLETED.
- -onSelectionChanged string
(default: "")
- Tcl command which is executed if
the item selected in the chooser id changed. Before evaluation
the following percent strings are substituted:
%f Name of the selected file. - -onUpdatePreview string
(default: "")
- TO BE COMPLETED.
- -overwriteConfirm boolean
(default: 0)
- Whether or to display a warning dialog if the user selects a file that already exists.
- -previewWidget string
(default: "")
- ID of a Gnocl widget to display
a custom preview of the currently selected file.
- -previewWidgetActive boolean
(default: 1)
- Whether the preview widget is
active.
- -selectFileName string
(default: "")
- TO BE COMPLETED.
-
-selectMultiple boolean (default:
0)
- Whether multiple files may be
selected.
- -showHidden boolean
(default: 0)
- Whether hidden files are shown.
- -title string
(default: "")
- Title of the dialog. -visible;
boolean; 1 Whether or not the item is visible.
Description
A fileChooserDialog is used to let the user select a directory or
one or more files in a standardized way.
This command has been available since GTK+ 2.4.
Commands
- id delete
- Deletes the widget and the
associated Tcl command.
- id configure
[-option value...]
- Configures the widget. Option
may have any of the values accepted on creation of the widget.
- id cget
option
- Returns the value for one
option. The option may have any of the values accepted by
configure.
Example
# basic Tcl/Gnocl Script
#!/bin/sh \
exec tclsh "$0" "$@"
package require Gnocl
proc changed {f w b1 b2} {
switch [file extension $f] {
.ogg -
.wav {
$w configure -visible 1
$b1 configure -onClicked "gnocl::sound $f"
$b2 configure -onClicked "gnocl::sound cancel"
}
default {
$w configure -visible 0
}
}
}
set but1 [gnocl::button -text PLAY ]
set but2 [gnocl::button -text STOP ]
set box [gnocl::box -children [list $but1 $but2] -visible 0 ]
gnocl::fileChooserDialog \
-extraWidget $box \
-title "Select Audio File" \
-onSelectionChanged {changed %f $box $but1
$but2}
gnocl::mainLoop
The second example shows how to set file filters for the
dialog.
# basic Tcl/Gnocl
Script
#!/bin/sh \
exec tclsh "$0" "$@"
package require Gnocl
set myFilters {Source {*.c *.tcl} Text {*.txt *.odt} Graphics
{*.png *.jpg *.tif} }
gnocl::window -child [gnocl::button \
-text click-me \
-onClicked {
puts [gnocl::fileChooserDialog \
-overwriteConfirm 1 \
-fileFilters $myFilters \
-currentFolder [pwd] \
-title
"Open Jiumoluo Project File -1"] }]
|