0

I only started to learn how to build GUIs. Is there any way to set the size of the textbox? I tried to use .geometry, but it was wrong:

from Tkinter import *

root = Tk()
root.title("boop")
root.geometry("500x700")

app = Frame(root)
app.grid()

msg = Text(app)
# msg.geometry("500x50") - this is what i tried, and was wrong.
msg.grid()

root.mainloop()

1 Answer 1

1

That can be done by using the height and width options:

# I just picked 50 and 500 to demonstrate
# You can tweak it to your needs
msg = Text(app, height=50, width=500)
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks, it is working. But i don't understate the measuring units, doesn't look like pixels or centimeters.
@KostyaKishnevsky - I have heard that the units are text units, or, namely, how much space it takes to type a monospace letter.
@Zipzap: the width and height attributes are based on the average width of a character in the font used by the widget. More specifically, I believe it is the width of the character "0" (zero). It should also be mentioned that setting the geometry (via root.geometry(...)) will potentially override the requested size of the widget.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.