| Ticket UUID: | 307b06cbc2f7e7d2da6e1f4fbe270e7ab0832ad4 | |||
| Title: | Gridded widget is not drawn in some cases (Aqua). | |||
| Type: | Bug | Version: | 9.0.2, 9.0.5, 9.1b1 | |
| Submitter: | SVIDevelopment | Created on: | 2025-07-18 12:24:50 | |
| Subsystem: | 49. [grid] | Assigned To: | jan.nijtmans | |
| Priority: | 5 Medium | Severity: | Minor | |
| Status: | Closed | Last Modified: | 2026-10-06 09:46:34 | |
| Resolution: | Duplicate | Closed By: | jan.nijtmans | |
| Closed on: | 2026-10-06 09:46:34 | |||
| Description: |
In the following script, when pressing the top button it should display the same number as the button below. However, on aqua the lower button lags behind, unless the last iteration in the loop triggers grid, not grid remove. When forcing an update by rescaling the window, the lower button shows the correct value again. The bug doees not appear without the update idletasks in updateButton.
-----------------------------------------------------------------------------
# This adjusts the counter (2 -> 1 -> 0 -> 2 -> etc), and then grids the
# button that displays that counter.
proc updateButton {} {
global counter, buttonCnt, buttonArr
incr ::counter $::buttonCnt
incr ::counter -1
set ::counter [expr {$::counter % $::buttonCnt}]
for {set i 0} {$i < $::buttonCnt} {incr i} {
if {$i == $::counter} {
grid $::buttonArr($i)
} else {
grid remove $::buttonArr($i)
}
# This update idletasks causes the gridded button to not get shown,
# unless the counter is $::buttonCnt - 1.
update idletasks
}
}
set top [toplevel .top]
tk::PlaceWindow $top
wm geometry $top 400x400
grid columnconfigure $top 0 -weight 1
grid rowconfigure $top 1 -weight 1
set counter 0
set buttonCnt 3
set button [button $top.button \
-textvariable ::counter \
-command [list updateButton] \
-fg red
]
grid $button -row 0 -column 0 -sticky news
for {set i 0} {$i < $buttonCnt} {incr i} {
set buttonArr($i) [button $top.button_$i -text $i -fg blue]
grid $buttonArr($i) -row 1 -column 0 -sticky news
}
# Update to grid the initial button, and remove the others.
updateButton
-------------------------------------------------------------------------------
| |||
| User Comments: |
jan.nijtmans added on 2026-10-06 09:46:34:
Dup of [2ef5dd8036] Closing serhiy.storchaka added on 2026-09-29 15:57:06:
As found below, Proposed fix in branch aqua-unmap-redraw: chrstphrchvz added on 2025-08-29 17:39:58: In the prototype CGImage drawing implementation, I had left a comment wondering if there was something missing from the end of XUnmapWindow() on Aqua: "Anything need to be done here instead? (Not yet aware of reasoning behind [78a3bdc4454f] i.e. why the existing approach uses addTkDirtyRect: here)". Well, X11 documentation of XUnmapWindow() mentions that "Unmapping a window will generate Expose events on windows that were formerly obscured by it." And the lack of redrawing on Aqua indeed seems to be caused by a lack of Expose events. So something like generateExposeEvents: or maybe TkMacOSXInvalidateWindow() could be worth trying, though I am not completely certain those will not introduce other issues. chrstphrchvz added on 2025-08-28 01:05:04: I believe this issue is at least partly due to a simpler, more general issue: on Tk Aqua 9.0, doing pack forget/place forget/grid forget/grid remove does not cause the container widget to be redrawn, leaving behind stale drawing of the previously-contained widget. I think this issue was not apparent on Tk Aqua 8.6 due to code near the end of XUnmapWindow() (tkMacOSXSubwindows.c) which forced redrawing to occur. In the reporter's example, when the counter is at 2, pressing the upper button causes these things to happen in order: lower button 1 is gridded, update idletasks is called, and lower button 2 is removed. So when update idletasks is called, both lower buttons 1 and 2 are gridded, and so both are redrawn; but since they are gridded in the same spot, only lower button 2 is visible since it is drawn last. When lower button 2 is then finally removed, no redrawing is done, leaving behind the stale drawing of lower button 2. chrstphrchvz added on 2025-08-13 01:56:17: I can reproduce this issue and its workaround on macOS with Tk Aqua 9.0, and cannot reproduce it on Windows, but I have not investigated it any further. | |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki