pass namespace name for script execution.
Sample :
button .b -namespace [ namespace current ] -command {
set flag "clicked"
}
bind .b <FocusIn> -namespace ::other {
set focusOwner %W
}
This solution maid tk script simple and more readable,
prevent global`ization. Also gain help for tk extensions.
Logged In: YES
user_id=80530
The traditional solution here, of course,
is to use [namespace code]:
Hmmm... tried to give an example
corresponding to yours, and I realize
I don't understand yours.
Care to spell things out in more detail?
Logged In: NO
sample - need pass value as arguments to proc
### current version ###
set data "pass there"
# next line true, but long and hard readable
button .b -command [ list [namespace current]::anyproc $data ]
bind .b <FocusIn> [ namespace code {
# next line wrong - variable `data` already changed or
unset`ted
anotherproc $data
} ]
### with -namespace option ###
button .b -namespace [namespace current]
.b configure -command [list anyproc $data]
.b bind <FocusIn> [list anotherproc $data ]
Code has been more readable,
bindings and commands scripts don`t
contain namespace names and may easy exported and reused.
This solution also open way to easy port old applications to
newest namespace model with minimal code changes.