Advanced Search
Mail us
Home    Manuel    Links    Faq    Submit a tcl/tk Reference    Contact Us

    Some examples tcl/tk codes     Man of Bwidget     Man of blt     mkwidget screenshots     TkOgl     Video Demo real.

  detect when the canvas has been resized?
 From Nathaniel Pryce :

> 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  "config %w %h"

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