Adjust a canvas as the window is resized

K Viltersten tmp1 at
Sat Mar 8 21:26:19 CET 2008

Do i need to set a callback to a canvas
in order to "listen" to the root window
being resized in order to make it adjust
its contents?

If so, how? If not, how do i make the
canvas draw a line from one corner to
an other?

from Tkinter import *

class Demo(Frame):
    def __init__(self, master = None):
        Frame.__init__(self, master)

    def doLayout(self):
        canvas = Canvas(self, bd = 3, bg = "#93F")
        canvas.grid(column = 0, row = 0)
        canvas.create_line(0, 0, 100, 200, fill = "#FFF")
    def callback(self):
        print "callback from canvas"
root = Tk()
demo = Demo(root)

Konrad Viltersten
sleep    - a substitute for coffee for the poor
ambition - lack of sense to be lazy

More information about the Python-list mailing list