On Thu, 30 Jan 1997 [EMAIL PROTECTED] wrote:
> One thing SpecTcl does well is generate code which can be embedded in
> other applications - it creates a proc per widget which accepts as an
> argument the name you wish to give the widget. This way, one is not
> bound to a specific name, and one can have a series of many widgets
> created in the same manner (as specified by the gui builder) any of
> which can be embedded inside other widgets.
I think a procedure per widget is a little heavy weight. My approach
has been to create reusable "compound" widgets and eliminate the
direct use of widget names when programming (from the user's perspective).
A compound is any arbitrary branch of the widget tree - usually starting
with a container frame. This can be encoded into a recursive list and
given a name. At any time, this string can be decoded and inserted
at any point in the widget tree - as many times as you like. There are
complicated reasons why widget names cannot remain the same in this
process and it has to do with retaining links such as between scrollbars
and listboxes. The way to access widgets is via "aliases" which is
an associative global array:
widget(<alias>)
which returns the widget path. During the encoding process for
compounds, widget aliases are also preserved. When the widget is
then re-inserted, the new alias the the widget is extracted as:
widget(<base>:<alias>)
where <base> is the root of the inserted compound.
There area few reasons I chose this method:
- it's pure tcl and doesn't require a new programming construct
the way SpecTcl does (with % to access widget names).
- I use the compound code for cut/paste.
- You can save and load libraries of custom compounds.
> Is this planned for vtcl, or already possible? I think it's a useful
> facility to have in addition to the current behavior (which I find a
> little unnecessarily intrusive upon the application structure, because
> it uses constant global names.)
the intrusiveness was necessary for the "widget" global. However, there
is also one other important distinction between the SpecTcl's usage and
Visual Tcl: Visual Tcl can import existing code and the format it saves
in is pure tcl. SpecTcl does not import code and is only designed to
generate GUI code snippets which you add to your own code - not entire
applications. It cannot import existing GUI code and does not support all
features of Tk (such as different geometry managers).
I do plan on making changes to the way the GUI code is generated to make
it more flexible (expecially toplevel generation). I also plan on
supporting multi-file projects - it's a matter of time.
-stewart-