summaryrefslogtreecommitdiffstats
path: root/library/demos/filebox.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'library/demos/filebox.tcl')
-rw-r--r--library/demos/filebox.tcl22
1 files changed, 14 insertions, 8 deletions
diff --git a/library/demos/filebox.tcl b/library/demos/filebox.tcl
index 5ac67cb..032e3d8 100644
--- a/library/demos/filebox.tcl
+++ b/library/demos/filebox.tcl
@@ -6,6 +6,8 @@ if {![info exists widgetDemo]} {
error "This script should be run from the \"widget\" demo."
}
+package require Tk
+
set w .filebox
catch {destroy $w}
toplevel $w
@@ -16,11 +18,9 @@ positionWindow $w
label $w.msg -font $font -wraplength 4i -justify left -text "Enter a file name in the entry box or click on the \"Browse\" buttons to select a file name using the file selection dialog."
pack $w.msg -side top
-frame $w.buttons
-pack $w.buttons -side bottom -fill x -pady 2m
-button $w.buttons.dismiss -text Dismiss -command "destroy $w"
-button $w.buttons.code -text "See Code" -command "showCode $w"
-pack $w.buttons.dismiss $w.buttons.code -side left -expand 1
+## See Code / Dismiss buttons
+set btns [addSeeDismiss $w.buttons $w]
+pack $btns -side bottom -fill x
foreach i {open save} {
set f [frame $w.$i]
@@ -33,7 +33,7 @@ foreach i {open save} {
pack $f -fill x -padx 1c -pady 3
}
-if {![string compare $tcl_platform(platform) unix]} {
+if {[tk windowingsystem] eq "x11"} {
checkbutton $w.strict -text "Use Motif Style Dialog" \
-variable tk_strictMotif -onvalue 1 -offvalue 0
pack $w.strict -anchor c
@@ -59,10 +59,16 @@ proc fileDialog {w ent operation} {
{"All files" *}
}
if {$operation == "open"} {
- set file [tk_getOpenFile -filetypes $types -parent $w]
+ global selected_type
+ if {![info exists selected_type]} {
+ set selected_type "Tcl Scripts"
+ }
+ set file [tk_getOpenFile -filetypes $types -parent $w \
+ -typevariable selected_type]
+ puts "You selected filetype \"$selected_type\""
} else {
set file [tk_getSaveFile -filetypes $types -parent $w \
- -initialfile Untitled -defaultextension .txt]
+ -initialfile Untitled -defaultextension .txt]
}
if {[string compare $file ""]} {
$ent delete 0 end