I'm trying to make a Tkinter entry box, but need more space than just one line. It seems that
self.scroll = ScrolledText.ScrolledText(self.tk).pack()
is the best looking way to do it right now, but I dont know how to get the inputted text from self.scroll and use it for something else, theres no clear documentation on it either. Does anyone know?
Mistake:
self.scroll = ScrolledText.ScrolledText(self.tk).pack()
this way you assign pack()
result to self.scroll
(not ScrolledText
)
and pack()
always returns None
.
Always:
self.scroll = ScrolledText.ScrolledText(self.tk)
self.scroll.pack()
And now see standard Text Widget documentation how to get/set text.
from tkinter import *
import tkinter.scrolledtext as ScrolledText
master = Tk()
st = ScrolledText.ScrolledText(master)
st.pack()
st.insert(INSERT, "Some text")
st.insert(END, " in ScrolledText")
print(st.get(1.0, END))
master.mainloop()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With