Python Forum

Full Version: Canvas Text Width/Height
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to figure out what the width and height of the text I am creating in Canvas are. I have tried using bbox as well as winfo_width()/winfo_height().
My pycharm doesn't seem to recognize winfo and gives me this error: "'int' object has no attribute 'winfo_width'".
When I do bbox, it gives me the same 4 coordinates, no matter how much I increase my text size: (-2 -2 3 3).
canvas1 = Canvas(root, width=self.widthImg, height=self.heightImg, borderwidth=0, highlightthickness=0, bg="white") 
text = canvas1.create_text(0, 0, font=(self.font.get(), self.inputSize.get()), fill="white", text=self.inputText.get())
x,y,x1,y1 = canvas.bbox(text)
print(x,y,x1,y1)
Any ideas?