tkinter window config event

Solutions on MaxInterview for tkinter window config event by the best coders in the world

showing results for - "tkinter window config event"
Malena
10 Nov 2016
1from Tkinter import *
2
3# create a canvas with no internal border
4canvas = Canvas(bd=0, highlightthickness=0)
5canvas.pack(fill=BOTH, expand=1)
6
7# track changes to the canvas size and draw
8# a rectangle which fills the visible part of
9# the canvas
10
11def configure(event):
12    canvas.delete("all")
13    w, h = event.width, event.height
14    print(w)
15    print(h)
16    xy = 0, 0, w-1, h-1
17    canvas.create_rectangle(xy)
18    canvas.create_line(xy)
19    xy = w-1, 0, 0, h-1
20    canvas.create_line(xy)
21
22canvas.bind("<Configure>", configure)
23
24mainloop()