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
-
By TextBox what do you meaning? Do you mean something similar to textarea that supports multi-line text instead of one line text?Partho63– Partho632019-02-13 09:07:20 +00:00Commented Feb 13, 2019 at 9:07
-
Yes, I mean a multi-line text with scrolling using a ttk widget - > from tkinter import ttkJavier– Javier2019-02-13 09:43:54 +00:00Commented Feb 13, 2019 at 9:43
Add a comment
|
1 Answer
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()
2 Comments
Javier
i want to use a ttk widget -> from tkinter import ttk
Bryan Oakley
@Javier: correct. As the answer says, ttk doesn't include a
Text widget.