How to get the width of tkinter widget?
问题 I'm trying to assign the width of a widget (in this case a label) to a variable. What I have so far: from tkinter import * def getwidth(): print(lbl.bbox()) root = Tk() lbl = Label(root, text="test text") lbl.grid(row=0) btn = Button(root, text="GO", command=getwidth) btn.grid(row=1) root.mainloop() I would have assumed that bbox() returns the offset from top left and the width and height, however, the returned value is {0, 0, 0, 0} . If someone could explain why this is and what would be the