Version 1 of Pure-Itcl widgets

Updated 2005-03-07 20:33:07 by Googie

Googie - There is a simpe way to write Itcl widgets, which work similar to Tk ones (becouse, as we know, Itcl objects work similar to Tk objects), but - it's important - without using itk (useful for starpacks).

To implement some widget, we need to write Itcl class like below:

 class Widget {
     constructor {args} {
         set w [lindex [split $this "::"] end] ;# here we hack object name to be [Tk] widet tree compatybile
         # here parsing options while constructing widget, such as colors, layout, etc
     }
     destructor {
         destroy $w
         # btw. - we need to bind $w destroying event to delete $this object
     }
     protected {
         variable w ;# this is our widget path
     }

     # and here, whatever you need...
 }

This allows to do the following:

 Widget .wid -some_option value
 pack .wid

 .wid some_method

...and Itcl syntax allows to implement such widgets in very, very easy way! :)

Have you some additional hints?