2 years ago

#5790

test-img

user16437736

Tkinter text block size

I'm recently working on a task, but I've encountered some problems. The result I want is this:

enter image description here

The problem is: The "place to type", should be immediately after my text, regardless of how long the text is. However, no matter what text I put, the "place to type" seems to remain in the same spot.

Long text: enter image description here

Short text: enter image description here

Here's my code:

from tkinter import *

window = Tk()
window.title("Test")
window.geometry("1500x1000")

title = Label(window, bg="lightblue", fg="black", text="Test", font=("Times New Roman", 60), pady=5, width=window.winfo_screenwidth())
label = Label(window, bg="white", fg="black", text="Statement", font=("Calibri", 40, UNDERLINE), pady=5, padx=10)

content = Text(window, bg="white", fg="black", wrap='word', font=("Sans Serif", 21), width=window.winfo_screenwidth())
content.insert('end', "***The text I want to insert***")
content["state"] = "disabled"
content["highlightthickness"] = 0
content["borderwidth"] = 0

text_edit = Text(window, width=56, height=25, bg="#0e0452", fg="white", font=("Rockwell", 20))

title.pack()
label.pack(anchor=NW)
content.pack(anchor=NW)
text_edit.pack(anchor=NW)

window.mainloop()

I think it's probably because of the "content" in my code, but I don't know how to fix it.

python

tkinter

tkinter-text

0 Answers

Your Answer

Accepted video resources