问题
What's the difference between tkinter's Entry()
and Text()
functions?
Couldn't find anything online, so after figuring it out, wanted to make it available online for others.
回答1:
Entry() allows one line of input:
Whereas, Text() allows multi-line inputs:
回答2:
Any documentation on Tkinter will tell you the answer. In fact, it's usually literally the very first thing it will tell you.
Entry in the Tkinter Book starts off with:
The Entry widget is a standard Tkinter widget used to enter or display a single line of text.
When to use the Entry Widget
The entry widget is used to enter text strings. This widget allows the user to enter one line of text, in a single font.
To enter multiple lines of text, use the Text widget.
Entry in the Tkinter reference starts with:
The purpose of an
Entry
widget is to let the user see and modify a single line of text.
- If you want to display multiple lines of text that can be edited, see Section 24, “The Text widget”.
And so on.
回答3:
The Entry widget has validation commands (ie, possibility to have only lowercase, only digits etc). This needs some workaround to make work in Text widgets.
来源:https://stackoverflow.com/questions/50194711/whats-the-difference-between-entry-and-text