Search code examples
tcltk-toolkit

Problem with tk_messageBox during Tcl/Tk initialization script


With the following Tcl script, the entry widget will not accept input. It appears but is unresponsive.

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

If I comment out the tk_messageBox line, then the entry widgets works fine. What causes this behavior and how do I fix it?

I'm using Tcl/Tk 8.5.2 on Windows.

To clarify, my problem is that the entry box is broken after the message box is dismissed. The entry box will not accept focus/input and will not display a caret. I've tested this on Windows XP and Vista, using Tcl/Tk I compiled myself, and with the tclkit from Equi4. In each case, the entry doesn't work if a message box is display in the initialization script.

Edit: One more thing. This "bug" is not present if the code is typed into an interactive wish console. It only seems to fail when the code is in a file and wish is invoked from the command line with the file name as an argument.


Solution

  • Apparently it is a bug in Tk.

    The simple fix is to put

    update idletasks
    

    as the first line of code in the initialization script.