In the following example, we have an application which has the following sources of configurable information:
#! /usr/tcl84/bin/tclsh package require Tk proc listResources { w } { set retval {} set head [tk appname]$w foreach tuple [$w configure] { if { [llength $tuple] == 5 } { lappend retval $head.[lindex $tuple 1] } } return $retval } option add *currentValue "None" widgetDefault # Pick up resources installed with application set scriptDir [file dirname [info script]] puts "scriptDir = $scriptDir" set programName [file tail $argv0] set defaultResources [file join $scriptDir $programName.def] puts "defaultResources = $defaultResources" catch {option readfile $defaultResources startupFile } # Pick up user defined resource file set userDefaults [file join $::env(HOME) "app-defaults" $programName] puts "userDefaults = $userDefaults" catch {option readfile $userDefaults userDefault } set b [button .button1 -textvariable currentValue -command [list exit]] if { $::argc > 0 } { if { [lindex $::argv 0] == "-currentValue" } { option add *currentValue [lindex $argv 1] 70 } } set currentValue [option get $b currentValue {}] puts "currentValue = $currentValue" pack $b # Uncomment these lines to display the resources used by the $b widget # foreach i [listResources $b] { # puts [format "%s: %s" $i [option get $b $i {} ]] # }