Tk Source Code

View Ticket
Login
Ticket UUID: 2effa4b31655ece489b4ae36154101df37a369f1
Title: tk version 8.6.4, windows 7 x64, window is not focused on create
Type: Bug Version: 8.6.4
Submitter: anonymous Created on: 2015-03-25 19:37:27
Subsystem: 68. Win Window Operations Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2026-09-25 17:26:57
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2026-09-25 17:26:57
Description:
When a tk program is run through wish on windows 7, using tk 8.6.4, and a window is created, it doesn't seem to be focused by default. I have tested with the following program:

 #! /bin/env tclsh
 package require Tk
 button .b -text {Push Me} -command {tk_messageBox -message {hello, world}}
 pack .b

When using jaws for windows (a screen reader I use as I am blind), it reports that there is no active window when I run that program through wish. Alt tabbing a few times will bring the window in focus.
Preferably the window should be focused automatically when created, to minimize problems and confusion for users of screen readers.
Thanks,
-Michael.
User Comments: jan.nijtmans added on 2026-09-25 17:26:57:

Fixed [891bf6ca31634e14|here], also backported to core-9-0-branch and core-8-6-branch

Many thanks!


serhiy.storchaka added on 2026-09-18 18:40:49:

Reproduced on Windows 11 with wish 8.6.18 and 9.1b1.

The withdrawn console toplevel is mapped before the main window, and UpdateWrapper() activates it as the first window of the thread. The activation is wasted on a hidden window, and the main window is never activated. Without a Tk console (e.g. Python/Tkinter) the main window is activated.

Fix in branch [ab44b5983a].


avl42 added on 2020-09-07 07:59:42:
I found this old ticket when searching for JAWS (screen reader)

I don't know much about the non-automatic focusing - I recently put an explicit focus command into a script of mine when running on windows, because it wasn't focused on start.  But that was more recent than this bug-report, or even stu's question, so I don't know if that was ever different on windows.

In my case, though, JAWS cannot determine the cursor position in a text widget, and it can only display the first two lines of the widget in the braille-simulation line. Clicking "next row" again with 2nd line shown had no effect.

I hope the originator of this thread still gets notifications for it.

stu added on 2018-01-12 22:05:11:
Is this a new behaviour?