Tkinter - getting canvas window size
Rick Pasotto
rickp at telocity.com
Tue Sep 18 12:35:48 EDT 2001
Why do the print statements in the following program show zero?
How can I figure out the size of the frame?
from Tkinter import *
w = Tk()
cnv = Canvas(w,bg='white',relief=SUNKEN)
cnv.config(width=400,height=200)
cnv.pack(side=LEFT,expand=YES,fill=BOTH)
f = Frame(cnv,relief=GROOVE,borderwidth=2)
for j in range(5):
l = Label(f,text='label: %2d' % (j),
relief=GROOVE,borderwidth=2,padx=5)
l.pack(side=LEFT,expand=YES,fill=X,padx=5,pady=2)
f.pack()
cw = cnv.create_window(20,20,window=f,anchor=NW)
print f.cget('height'),f.cget('width')
print cnv.itemcget(cw,'height'), cnv.itemcget(cw,'width')
w.mainloop()
--
Property is prior to law; the sole function of the law is to
safeguard the right to property wherever it exists, wherever it is
formed, in whatever manner the worker produces it, whether
individually or in association, provided that he respects the
rights of others.
-- Frédéric Bastiat (1801-1850)
Rick Pasotto rickp at telocity.com http://www.niof.net
More information about the Python-list
mailing list