python - Is Tkinter winfo_reqwidth "always up to date"? -


from documentation:

w.winfo_width()  returns current width of w in pixels. see remarks on geometry updating under .winfo_geometry(), above. may prefer use .winfo_reqwidth() method, described above; date. 

not according experience. following program prints same value twice after each click on label. value changes line line.

from tkinter import *  root = tk() t = "a label" padx = 0 f = frame(root, padx=padx, bg='red') l = label(f, text=t, bg='yellow') def cb(e):     global t, padx     w = f.winfo_reqwidth()     print w,     t = t + 'x'     padx += 10     f.configure(padx=padx)     l.configure(text=t)     #f.update_idletasks()     w = f.winfo_reqwidth()     print w f.place(x=0,y=0) l.pack() l.bind('<button-1>', cb) mainloop() 

prints:

49 49 76 76 103 103 

uncomment f.update_idletasks line , prints:

49 76 76 103 103 130 

is documentation wrong? reading wrong? there way retrieve required width , height of widget after changing it?


Comments