home *** CD-ROM | disk | FTP | other *** search
-
- class guiStringFile {
- inherit guiString
- variable button
- constructor {frame xuiString} {
- guiString::constructor $frame $xuiString
- } {
- set button [Button $frame.b -image openFolder]
- $button configure -command [code $this askFile]
- pack $button -side left -padx 3 -anchor w
- }
- method enable
- method disable
- method askFile
- }
-
- body guiStringFile::askFile {} {
- set title [$labelEntry cget -label]
- set initialdir [file dirname $value]
- if ![file exists $initialdir] {
- set initaldir /
- }
- if [catch {set file [tk_getOpenFile \
- -initialdir $initialdir -title $title]}] {
-
- # If we do not have access to the directory (wrong permissions) just open default /
- set file [tk_getOpenFile \
- -initialdir / -title $title]
- }
- if [string length $file] {
- set value $file
- sync
- }
- }
-
- body guiStringFile::enable {} {
- $button configure -state normal
- guiString::enable
- }
-
- body guiStringFile::disable {} {
- $button configure -state disabled
- guiString::disable
- }
-
-