Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tk_getSaveFile and types

Status
Not open for further replies.

aleph1ow

Programmer
Jun 20, 2007
3
IT
Hi all,
I've writed a simple tcl/tk text editor.
I save trough the "tk_getSaveFile" macro with the option "-filetypes $types" and I've defined the "types" variable in this way:

set types {
{"All files" *}
{"CPLEX LP" {.lp}}
{"MPS" {.mps}}
{"Text" {*.txt}}
}

Under the WindowsXP platform I open the save window, I select the file type I want to save trough the select box, then I type the file name (test) without extension, and press "save",but the file name doesn't get the extension! The only way is to type the extension by hand like "test.txt".
Under Linux everything works...why? Do I have to enable or disable any tcl_platform option?
Thanks in advance
Paolo
 
The -filetypes option has nothing to do with adding an extension, only with with extensions will be visisble in the dialog. To use a default extension, on Windows at least, you need to use (no surprise here) the -defaultextension option:
-defaultextension extension
Specifies a string that will be appended to the filename if the user enters a filename without an extension. The defaut value is the empty string, which means no extension will be appended to the filename in any case. This option is ignored on the Macintosh platform, which does not require extensions to filenames, and the [red]UNIX implementation guesses reasonable values for this from the -filetypes option when this is not supplied[/red].

_________________
Bob Rashkin
 
Now it works also under Windows platform:)
Thanx a lot!

Paolo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top