Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bind in Snit megawidgets

25 views
Skip to first unread message

Silas

unread,
May 23, 2012, 4:51:12 PM5/23/12
to
Hi there!

I'm trying to bind a event of a Snit megawidget. I call it Xtext and
it is a wrapper around [text] widget. I'd like to bind all Xtext of
the application. I'm trying:

bind Xtext <Button-3> {puts something}

But this doesn't work. The following, thought, works:

bind Text <Button-3> {puts something}

But it is unwanted, since it bypass all nice wrapper I made around
[text] that I wanted to use. It seems that new classes that snit
creates don't work well for binds.

Any tips?

Thank you.

Will Duquette

unread,
May 23, 2012, 6:57:46 PM5/23/12
to
The text widget you're wrapping is still a [text] widget; so its
bindtags include Text, not Xtext. Replace Text with Xtext in the
bindtags, and you should be good to go.

Silas

unread,
May 23, 2012, 7:44:12 PM5/23/12
to
On May 23, 7:57 pm, Will Duquette <w...@wjduquette.com> wrote:
> The text widget you're wrapping is still a [text] widget; so its
> bindtags include Text, not Xtext.  Replace Text with Xtext in the
> bindtags, and you should be good to go.

Yes, it works as people told me on the chat. There is a little
problem, though. When binding the widget, the %W substitution
substitutes to the [text], not my megawidget (so I cannot use my
megawidget methods). Should I use [winfo parent %W]? It looks ugly,
but if it is the only way...

Thanks.

Will Duquette

unread,
May 23, 2012, 10:26:54 PM5/23/12
to
If your megawidget is only and entirely a wrapped text widget, you can
use a snit::widgetadaptor, and %W will be the text widget. If you're
wrapping other widgets in as well (i.e., scrollbars) then that won't
work, and [winfo parent %W] is what you'll need to do.

Robert Heller

unread,
May 24, 2012, 8:25:00 AM5/24/12
to
At Wed, 23 May 2012 16:44:12 -0700 (PDT) Silas <sil...@gmail.com> wrote:

>
> On May 23, 7:57=A0pm, Will Duquette <w...@wjduquette.com> wrote:
> > The text widget you're wrapping is still a [text] widget; so its
> > bindtags include Text, not Xtext. =A0Replace Text with Xtext in the
> > bindtags, and you should be good to go.
>
> Yes, it works as people told me on the chat. There is a little
> problem, though. When binding the widget, the %W substitution
> substitutes to the [text], not my megawidget (so I cannot use my
> megawidget methods). Should I use [winfo parent %W]? It looks ugly,
> but if it is the only way...

Don't put the tags on the 'inner' component widget, put it on the
container widget (usually a frame, but you can change that). If the
*only* component of your megawidget is the text widget, then you can
create a snit::widetadapter instead of a snit::widget and make the hull
the text widget itself.

>
> Thanks.
>

--
Robert Heller -- 978-544-6933 / hel...@deepsoft.com
Deepwoods Software -- http://www.deepsoft.com/
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments



0 new messages