hwtk::openfileentry
Pop up a dialog box for the user to select a file to open or save.
Format
hwtk::openfileentry - pathName ?option value? …
Description
Its purpose is for the user to select an existing file only. If the user enters a non-existent file, the dialog box gives the user an error prompt and requires the user to give an alternative selection. If an application allows the user to create new files, it should do so by providing a separate New menu command.
Standard Options
- -clientdata
- Database name: clientData
- -cursor
- Database name: cursor
- -help
- Database name: help
- -helpcommand
- Database name: helpcommand
- -marker
- Database name: marker
- -state
- Database name: state
- -takefocus
- Database name: takeFocus
- -textvariable
- Database name: textVariable
- -width
- Database name: width
Widget-Specific Options
- -buttonpos
- Database name: buttonpos
- -command
- Database name: command
- -defaultextension
- Database name: defaultextension
- -filetypes
- Database name: filetypes
- -initialdir
- Database name: initialdir
- -initialfile
- Database name: initialfile
- -invalidcommand
- Database name: invalidCommand
- -justify
- Database name: justify
- -marker
- Database name: marker
- -multiple
- Database name: multiple
- -parent
- Database name: parent
- -show
- Database name: show
- -title
- Database name: title
- -typevariable
- Database name: typevariable
- -validate
- Database name: validate
- -validatecommand
- Database name: validateCommand
Widget Command
- pathName configure ?option? ?value option value …?
- Query or modify the configuration options of the widget. If one or more option-value pairs are specified, then the command modifies the given widget option(s) to have the given value(s); in this case the command returns an empty string. If option is specified with no value, then the command returns a list describing the named option: the elements of the list are the option name, database name, database class, default value, and current value. If no option is specified, returns a list describing all of the available options for pathName.
- pathName cget option
- Returns the current value of the configuration option given by option.
- pathName identify element x y
- Returns the name of the element under the point given by x and y, or an empty string if the point does not lie within any element. x and y are pixel coordinates relative to the widget. Some widgets accept other identify subcommands.
- pathName instate statespec ?script?
- Test the widget’s state. If script is not specified, returns 1 if the
widget state matches statespec and 0 otherwise. If script is specified,
equivalent to
if{[pathNameinstatestateSpec]}script
- pathName state ?stateSpec?
- Modify or inquire widget state. If stateSpec is
present, sets the widget state: for each flag in
stateSpec, sets the corresponding flag or clears it
if prefixed by an exclamation point. Returns a new state spec indicating
which flags were changed:
will restore pathName to the original state. If stateSpec is not specified, returns a list of the currently-enabled state flags.setchanges[pathNamestatespec]
pathNamestate$changes
- pathName bbox index
- Returns a list of four numbers describing the bounding box of the character given by index. The first two elements of the list give the x and y coordinates of the upper-left corner of the screen area covered by the character (in pixels relative to the widget) and the last two elements give the width and height of the character, in pixels. The bounding box may refer to a region outside the visible area of the window.
- pathName delete first ?last?
- Delete one or more elements of the entry. First is the index of the first character to delete, and last is the index of the character just after the last one to delete. If last isn’t specified it defaults to first+1, that is, a single character is deleted. This command returns the empty string.
- pathName get
- Returns the entry’s string.
- pathName icursor index
- Arrange for the insert cursor to be displayed just before the character given by index. Returns the empty string.
- pathName index string
- Arrange for the insert cursor to be displayed just before the character given by index. Returns the empty string.
- pathName insert index string
- Insert string just before the character indicated by index. Returns the empty string.
- pathName selection option arg
- This command is used to adjust the selection within an entry. It has
several forms, depending on option:
- pathName selection clear
- Clear the selection if it is currently in this widget. If the selection isn’t in this widget then the command has no effect. Returns the empty string.
- pathName selection present
- Returns 1 if there is are characters selected in the entry, 0 if nothing is selected.
- pathName selection range start end
- Sets the selection to include the characters starting with the one indexed by start and ending with the one just before end. If end refers to the same character as start or an earlier one, then the entry’s selection is cleared.
- pathName set str
- Sets the entry’s value to str.
- pathName xview args
- This command is used to query and change the horizontal position of the
text in the widget’s window. It can take any of the following forms:
- pathName xview
- Returns a list containing two elements. Each element is a real fraction between 0 and 1; together they describe the horizontal span that is visible in the window. For example, if the first element is .2 and the second element is .6, 20% of the entry’s text is offscreen to the left, the middle 40% is visible in the window, and 40% of the text is offscreen to the right. These are the same values passed to scrollbars via the -xscrollcommand option.
- pathName xview index
- Adjusts the view in the window so that the character given by index is displayed at the left edge of the window.
- pathName xview moveto fraction
- Adjusts the view in the window so that the character fraction of the way through the text appears at the left edge of the window. fraction must be a fraction between 0 and 1.
- pathName xview scroll number what
- This command shifts the view in the window left or right according to number and what. Number must be an integer. What must be either units or pages. If what is units, the view adjusts left or right by number average width characters on the display; if it is pages then the view adjusts by number screenfuls. If number is negative then characters farther to the left become visible; if it is positive then characters farther to the right become visible.
Example
hwtk::dialog .d -title "::hwtk::openfileentry"
set w [.d recess]
grid [hwtk::label $w.11 -text Enabled] [hwtk::openfilentry $w.openFile1]
grid [hwtk::label $w.12 -text Disabled] [hwtk::openfilentry $w.openFile2 -state disabled]
grid [hwtk::label $w.13 -text Multiple] [hwtk::openfilentry $w.openFile3 -multiple 1]
.d post
$w.openfile configure -buttonpos left
$w.openfile configure -multiple 1
.d post