Tk Source Code

View Ticket
Login
Ticket UUID: 1303103
Title: -namespace option for "bind" and widgets
Type: RFE Version: None
Submitter: nobody Created on: 2005-09-24 11:01:54
Subsystem: 01. Bindings Assigned To: hobbs
Priority: 5 Medium Severity:
Status: Open Last Modified: 2005-09-30 13:49:13
Resolution: None Closed By:
    Closed on:
Description:
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.
User Comments: nobody added on 2005-09-30 13:49:13:
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.

dgp added on 2005-09-26 13:00:44:
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?