Menu

#2655 focus problems during startup of wish application in windows

open
5
2009-07-06
2009-07-06
mike
No

Take any simple Tk application, like --> pack [button .b1 -text "Exit" -command exit]
run with
wish85.exe simple.tcl
When the application starts up, it does not have the system focus. Before manually focusing the app (with a mouse click), if I press Alt-Tab (Windows task switcher), I see 2 "Tk" tasks. One is my application, the other is labeled "Console". But I never asked for a console in my app. Also,
there is no visible console window on the screen, nor is there a console on my task bar or in the Windows "Close Program" dialog.
- If I either Alt-Tab my way to the app (which focuses it), or if I mouse click on the app to focus it, the "Console" task goes away and the application reacts normally. Basically, once the app *is* focused once, all is normal. It just doesn't receive focus by default for some reason and has this weird "Console" task hanging around until it is focused.
I have temporarily fixed the problem by placing a "focus -force ." in my application code, which does seem to work.

This happens on Windows 98/NT/XP
On Vista you still get the focus problem, but you don't get the extra "console" icon in the windows task switcher window.

It only happens when you run from wish. Running from tclsh it works fine.

Discussion