Version 5 of tkwait visibility

Updated 2015-12-11 15:28:48 by oehhar
tkwait visibility name

Waits for a change in the visibility state (as indicated by the arrival of a <VisibilityNotify> event) of window name. This is typically used to wait for a newly-created window to appear on the screen before taking some action. Returns an empty string.

Note that this command is not particularly useful on non-X11 platforms (Windows, OSX/Aqua) because <VisibilityNotify> events are never delivered. This is a platform limitation.

HaO 2015-12-03: I dod not know that tkwait visibility does not work on windows.

HaO 2015-12-11: I face the issue, that tkwait never returns when the window is already visible. Is there a way to check this. Aim is just to asure that window is visible like:

if {![window already visible]} { tkwait visibility $w }

  Windows bug or whatever - looking for help

HaO 2015-12-02:

I had an issue today with tkwait visibility, I could not really track down.

A large application does the following:

# hide main window on initialisation
wm deiconify .
update
# initialisation of many things including main window
wm state . normal
catch {tkwait visibility .} ;# if error etc ommitted for clarity
wm geometry . $SavedGeometry

Under strange totally unrelated circumstances (empty config file not present)but repeatable, the tkwait waits forever.

Thus, I have modified it as follows:

# hide main window on initialisation
wm deiconify .
update
# initialisation of many things including main window
wm state . normal
if {[winfo ismapped .]} {
    catch {tkwait visibility .} ;# if error etc ommitted for clarity
}
wm geometry . $SavedGeometry

The "winfo ismapped" is only 0 if the tkwait will stall. I tried thousands of other things including update, wm deiconfy etc. With the upper patch, the window shows up quite delayed when tkwait is not used, but it shows up. The wm geometry is eventually not correctly honored (what the tk visibility is for) but that is better than nothing.

Anybody with the same experience may add to wether nail it down to a test script or whatever.

This is:

  • TCL 8.6.4 32 bit
  • Windows 10 64 bit (German)