Hi Robert,
I think what you try is virtually impossible and that is due to the
special nature of Dialogs.
BWidget was designed for megawidgets consisting typically of a frame
with subwidgets .framename.subwidgetName.
This model doesn't work for dialogs because dialogs are always toplevel
widgets.
So DisplayOneTrain and TtStdShell and Dialog should all be toplevel
widgets which defies hierarchical window names; you end up with all
megawidgets having the same pathname.
Each megawidget creates a command named after the pathname so these
commands overwrite.
BWidgets has only one level of retaining ($path becomes $path:cmd in
Widget::create) while you seem to need 4.
BWidgets also keeps track of what class a given widget is in variable
::Widget::_class($path).
Since all megawidgets have the same pathname it will think that $path is
a DisplayOneTrain, while you also need subwidgets of TtStdShell and
Dialog type.
Personally, I think it is hopeless.
Some minor remarks about your code:
1) the options mentioned in initialize should also be in include (or
there should not be an include at all).
2) Initialize means exactly that, it initializes, what you seem to want
is making the options you mention in initialize immutable, this is done
by adding them in the create routine.
3) You can't initialize -class; class determines what option is written
in the option-database and that is what bwinclude actually does so you
have a chicken and egg problem.
4) syncoptions does nothing, you can remove it.
As for documentation, what makes BWidgets tick is file widget.tcl. I
think you should try to read the source. If I remember correctly there
is an old overview on the wiki written by a Belgian.
Good Luck,
Michiel
Robert Heller schreef:
> One thing I liked about Tix was its excellent documentation, but for a
> variety of reasons, I need to use a different mega-widget package.
> BWidget seems (on the surface) as good, if not better, but I am having
> some problems getting some things to work. I suspect most of my
> problems are caused by a lack on good documentation. Is there in fact
> some *better* (more in depth) documentation available? Other than the
> rather brief and sparse HTML docs that are distributed with the BWidget
> package?
>
> Anyway, I am trying to create a specialized Dialog class, based on the
> existing Dialog class. I have declared the class like this:
>
> namespace eval TtStdShell {
> Widget::define TtStdShell TTMainWindow Dialog Label
>
> Widget::bwinclude TtStdShell Dialog .dialog \
> include {-title -class} \
> initialize {-class TtStdShell -image banner -default 0 -cancel 0 \
> -modal none -transient yes -parent . -side bottom}
> Widget::syncoptions TtStdShell Dialog .dialog {-title {}}
> Widget::bwinclude TtStdShell Label .dialog.bannertext \
> include {} \
> rename {-text -label} \
> initialize {-anchor w -font {Helvetica -24 bold}}
> Widget::syncoptions TtStdShell Label .dialog.bannertext {-label -text}
> Widget::syncoptions TtStdShell Dialog .dialog {-title {} -class {}}
> ::bind BwTtStdShell <Destroy> [list TtStdShell::_destroy %W]
> }
>
> But I have discovered that when I use this class to build other Dialog
> classes, I am having problems with some of the settings getting
> propagated. I am declaring a sub class like this:
>
> namespace eval DisplayOneTrain {
> Widget::define DisplayOneTrain TTTrains TtStdShell PanedWindow ScrolledWindow \
> ScrollableFrame
> Widget::bwinclude DisplayOneTrain TtStdShell .dialog \
> include {-title -label} \
> initialize {-title "Displaying one train" -label "Displaying one train"}
> Widget::syncoptions DisplayOneTrain TtStdShell .dialog {-title {} -label {}}
> Widget::bwinclude DisplayOneTrain PanedWindow .schedNotes \
> include {} \
> initialize {-side right}
> Widget::bwinclude DisplayOneTrain ScrolledWindow .schedscroll \
> include {} \
> initialize {-scrollbar both -auto both}
> Widget::bwinclude DisplayOneTrain ScrollableFrame .schedscroll.sched \
> include {} \
> initialize {-width 300 -height 150}
> Widget::bwinclude DisplayOneTrain ScrolledWindow .notescroll \
> include {} \
> initialize {-scrollbar both -auto both}
> Widget::tkinclude DisplayOneTrain text .notescroll.notes \
> include {} \
> initialize {-height 8 -width 24}
> Widget::declare DisplayOneTrain {
> {-train String "" 0}
> }
> ::bind BwDisplayOneTrain <Destroy> [list DisplayOneTrain::_destroy %W]
> }
>
> I have discovered that I need to *explicitly* replicate the options in
> the initialize sections of the bwinclude calls in both the create
> functions in order for them to take effect, otherwise I get base widget
> defaults imposed. *Other* widgets I have built don't have this problem
> (or at least I am not seeing them). It in unclear (from the fairly
> *sparse* documentation) what I am doing wrong.
>
>
> \/
> Robert Heller ||InterNet: heller@deepsoft.com
> http://www.deepsoft.com/ ||FidoNet: 1:321/153
> http://www.deepsoft.com/~heller /\
>
>
>
>
>
>
>
Received on Sun Apr 30 02:17:41 2006