- update idletasks
(From Joe from clt)As noted, most Tk widgets redraw themselves at idle-time, so update idletasks will perform any pending redisplays.They generally *schedule* redisplays in response to <Expose> and <Configure> events, and these come in through the main event loop. So if you update idletasks immediately after packing a window, it won't necessarily redraw itself because it might not know that it needs to be redrawn yet!You can see this in action if you add the following to the original test script:
bind all <Map> { puts "MAP: %W" } bind all <Expose> { puts "EXPOSE: %W" }You can force a redisplay without reentering the main event loop by sending a synthetic <Expose> event:
pack $w ... event generate $w <Expose> -when now update idletasks('-when now' is the default for event generate, so strictly speaking it's unnecessary, but I like to write it out explicitly in cases where it makes a difference, as it does here.)MHo 2012-03-13 I have a situation here where the trick shown above does not force redraw. Up until now the only way is a full update...