Canvas Text Width/Height - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: Canvas Text Width/Height (/thread-12334.html) |
Canvas Text Width/Height - Anysja - Aug-20-2018 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? |