2

I am using ttk widgets for tkinter GUI. I wonder how to construct a TextBox using a TTK widgets. I can't find the equivalent TextBox widget as TTK

2
  • By TextBox what do you meaning? Do you mean something similar to textarea that supports multi-line text instead of one line text? Commented Feb 13, 2019 at 9:07
  • Yes, I mean a multi-line text with scrolling using a ttk widget - > from tkinter import ttk Commented Feb 13, 2019 at 9:43

1 Answer 1

2

The Text widget is not available in ttk. Python - Text widget from tkinter in tkk

You can use Text. Here is an example:

from tkinter import *

r = Tk()

text = """Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque non ornare leo, nec pulvinar augue. Nam imperdiet sem eu quam placerat, placerat fermentum leo ornare. Sed malesuada non urna vel finibus. Vestibulum condimentum gravida nunc, faucibus malesuada augue laoreet sed. Pellentesque consectetur orci in felis lacinia finibus. Vestibulum luctus est quis velit hendrerit, et mattis neque pretium. Duis eget urna tristique, viverra ligula id, lacinia felis. Suspendisse potenti. Etiam nisi quam, tincidunt non risus a, rhoncus vulputate augue. Morbi molestie sagittis lectus, non lacinia eros pellentesque in.

Integer aliquet finibus sapien at feugiat. Fusce lobortis vulputate ex, vitae faucibus nunc eleifend eu. Pellentesque hendrerit tortor a est vulputate, vel porttitor eros pretium. Pellentesque rhoncus felis imperdiet, lacinia dolor sed, tempus eros. Duis placerat fringilla pulvinar. Maecenas erat nisl, consectetur ac ipsum sed, hendrerit fermentum leo. Suspendisse sed tortor ultricies lacus porttitor viverra. Aenean quis imperdiet nulla. Vivamus a sem tellus. Ut vitae neque a enim bibendum euismod."""

t = Text(r)
t.pack(fill=BOTH, expand=1)
t.insert("end", text)

r.mainloop()
Sign up to request clarification or add additional context in comments.

2 Comments

i want to use a ttk widget -> from tkinter import ttk
@Javier: correct. As the answer says, ttk doesn't include a Text 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.