Re: GUI, namespaces and OO
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Re: GUI, namespaces and OO

From: Aric Bills <aric.bills@gmail.com>
Date: Sun Oct 30 2005 - 00:01:54 CEST

Snit will do that, and a lot more, for you. Below is a Snit
translation of your code, which will automatically clean up the
variable and namespace when the toplevel is deleted. For something so
trivial, it looks like a lot of extra stuff, but for a real-world
widget of any complexity, the Snit code is likely to be shorter and
guaranteed to be more elegant than the non-Snit version.

The "Snit FAQ" is an excellent tutorial:
http://www.wjduquette.com/snit/snitfaq.html

Regards,
Aric

package require snit

snit::widget twidget {

    hulltype toplevel
    variable entryvalue
    component myentry

    constructor {args} {
        install myentry using entry $win.myentry \
            -textvariable [myvar entryvalue]
        grid $myentry
    }
}

twidget .t
Received on Mon Nov 21 00:37:07 2005