Attachment "exercise.tcl" to
ticket [a296cf46]
added by
erikleunissen
2022-04-09 12:26:14.
#! /bin/sh
# If executed as a shell script, the next line replaces the shell \
exec tclsh "$0" ${1+"$@"}
package require Tk
pack propagate . 0
frame .f1 -width 80 -height 80 -bg blue
pack propagate .f1 0
pack .f1
update idletasks
puts |[.f1 cget -width]|[winfo width .f1]|
after 1000
# configure .f1 to shrink arounf its child window
frame .f1.f2 -bg yellow -width 30 -height 30
pack propagate .f1 1
pack .f1.f2
update idletasks
puts |[.f1 cget -width]|[winfo width .f1]|
after 1000
# After restoring the non-propagation setting, .f1 is not restored
# to its configured size. (We demonstrate with output for
# the width only; height behaves similarly.)
pack propagate .f1 0
update idletasks
puts |[.f1 cget -width]|[winfo width .f1]|
after 1000
# Not even when it is temporarily unpacked.
pack forget .f1
pack propagate .f1 0
pack .f1
update idletasks
puts |[.f1 cget -width]|[winfo width .f1]|
after 1000
# And not even when the child window, around which the shrinking
# happened, is destroyed.
pack forget .f1
destroy .f1.f2
pack .f1
update idletasks
puts |[.f1 cget -width]|[winfo width .f1]|
after 1000
# Adjusting the actual size to the configured size requires
# another explicit, but seemingly useless widget reconfiguration command,
# using the values for width/height that it already is configured with.
.f1 configure -width [.f1 cget -width] -height [.f1 cget -height]
update idletasks
puts |[.f1 cget -width]|[winfo width .f1]|
vwait forever; # attach TkCon for introspection if desired