[Xotcl] XOTcl Megawidgets

Uwe Zdun uwe.zdun at wu-wien.ac.at
Thu May 15 10:42:55 CEST 2003


Hi,

you're right, there is no mega-widget packet for XOTcl (I often use Tcl 
megawidgets such as Bwidgets) ... yet it is 
quite simple to integrate Tk and XOTcl; and build you're own megawidgets.
I found that wrapping the simple Tk widgets (or Bwidgets) does not make too 
much sense, but building classes that represent more complex GUI elements is 
very useful. The most simple thing you can do is to store the widget
IDs of the associated widget in a variable on the object representing it.

As said before, I do not use an integration <one widget == one object>
anymore but let the objects aggregate more than one widget. As for instance
a class TextEditor that contains a ScrolledWindow, a ctext, and some buttons. 

I often integrate the name of the object and the name of the top
widget in such composite widgets. Here you have to be careful, the object name 
returned by [self] contains "::" which you have to strip. Also object names 
can potentially start with an upper case letter, widget IDs not. I only use 
lower cases object names, so I can do something like:

  button .[namespace tail [self]]

in the constructor. Or you replace the "::"'s with "."'s, if you want to
use XOTcl aggregation to model a class hierarchy.

Another issue is callback commands. You usually want them to be dispatched
on the object. Then you cannot do something like:
  
   button .[namespace tail [self]] -command {[self] doSometing}

as the self is replaced in the wrong scope (of the callback) (because of the 
brackets: {}) and does
not find the object. Instead you have to use substitution:

  button .[namespace tail [self]] -command [list [self] doSometing]

If you want to see some nice larger examples, download XOTclIDE 
(www.xdobry.de/xotclIDE) and look at the file IDEBaseGUI.xotcl ...

Uwe

On Thursday 15 May 2003 08:09, Nicolas Boretos wrote:
> Hi,
>
> I am fairly new to XOTcl and this list, but so far I like XOTcl..
> Recently on clt, this was posted regarding tk widgets/framework
>
> ----snip---
> I haven't looked recently.  Tix is technically adequate, I suspect,
> but there are cleaner ways of doing OO.  My vote would be for
> something based on XOTcl---it seems to have about the best performance
> of the various OO frameworks, and it feels more like Tcl than (say)
> [incr Tcl].  On the other hand, [incr Tcl] has a nice set of
> megawidgets in [incr Widgets], so it's more nearly there.
>
> Is there any thoughts on anything like this from the XOTcl team...
>
> regards,
>
> nicolas
>
>
>
>
>
> _______________________________________________
> Xotcl mailing list  -  Xotcl at alice.wu-wien.ac.at
> http://alice.wu-wien.ac.at/mailman/listinfo/xotcl

-- 
Uwe Zdun
Department of Information Systems, Vienna University of Economics
Phone: +43 1 313 36 4796, Fax: +43 1 313 36 746
zdun@{xotcl,computer,acm}.org, uwe.zdun at wu-wien.ac.at





More information about the Xotcl mailing list