-Q10.E.4- detect when the canvas has been resized?

From: -X-  How, in Tk, can I XXX:

A10.E.4. From Nathaniel Pryce <np@hpl.hp.co.uk>:

> I have a window with a canvas containing some stuff that logically
> fills the canvas (say, a chess board or a map of the world). I want
> this toplevel window to be resizable and of course, when the win is
> resized, I want the stuff inside the canvas to be scaled
> accordingly. Now, I can manage the scaling of the stuff, but what
> I'm having trouble with is DETECTING that I should do it. How can I
> be notified that the window has been resized?

Nat's answer is:

You need to bind a command to the Configure event, like this:

	proc config {w h} {
	   puts stdout ".canvas - width = $w, height = $h"
	}

	bind .canvas <Configure> "config %w %h"


.canvas - width = 224, height = 251
.canvas - width = 224, height = 151
.canvas - width = 224, height = 243
# and so forth
Go Back Up

Go To Previous

Go To Next