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

Problem with message box during Tcl/Tk initialization script.

31 views
Skip to first unread message

Lewis

unread,
Jan 17, 2010, 2:06:25 PM1/17/10
to
I'm fairly new to Tcl/Tk, and so far I am loving it. I do have a
little problem, though, I hope someone can help me with.

It appears that if a tk_messageBox is displayed in an initialization
script, that some widgets break.

Here is a script to demonstrate my problem:

pack [entry .a]
tk_messageBox -message {test}

When I run this script, the message box pops up. After I dismiss the
message box, the entry widget will not accept input. I cannot even get
a caret to appear in the entry box. Clicking, tabbing, and right
clicking seem to have no effect. If I comment out the message box
line, then the entry box appears to work as normal.

I have tested this on two computers (XP and Vista) with the same
result. I have tired Tcl/Tk 8.5.2 and 8.5.1. It always works the same
way for me.

I found the following work around to work fine:

pack [entry .a]
after 100 {tk_messageBox -message {test}}

The message box is displayed, and after it's dismissed the entry
widget works fine.

So, my question: is this normal? What causes this? Are modal dialogs
not allowed in initialization scripts?

Thanks.

Eric Hassold

unread,
Jan 17, 2010, 2:38:32 PM1/17/10
to
Hi,

This is a bug, caused by a native window dialog getting focus before Tk
toplevel is actually mapped. A simple workaround consists in enforcing
toplevel window to be mapped as soon as possible, by invoking:

update idletasks

right after Tk package is loaded, or, in any case, before any Win32
native dialog (message box, file dialog, ...) is displayed.

For reference, this bug has been discussed recently on c.l.t.:

http://groups.google.fr/group/comp.lang.tcl/browse_thread/thread/d3e5a5081c11b4f0/8596874f096ff64a

and reffers to this older post:

http://groups.google.fr/group/comp.lang.tcl/browse_thread/thread/80010819b7e94a29/86b800ebe9622b7c

A ticket has been created for it in Tk bug tracker:

http://sourceforge.net/tracker/?func=detail&aid=2001072&group_id=12997&atid=112997


Eric

-----
Eric Hassold
Evolane - http://www.evolane.com/

Lewis

unread,
Jan 17, 2010, 4:02:12 PM1/17/10
to
Eric,

Thank you very much for your quick, detailed, and helpful answer.

Sorry for duplicating a recently asked question.

Thanks,
Lewis

0 new messages