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

    From: -II-  Tk Questions and Answers - How can I:

    A2.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

Parent document is top of "FAQ: comp.lang.tcl Tk Toolkit Usage Questions And Answers (1/1)"
Previous document is "-Q2.E.3- raise/lower canvas window objects or draw graphics onto a window object inside a canvas?"
Next document is "-Q2.E.5- scroll a canvas an a listbox at the same time with one scrollbar?"