Вам не хватает трех вещей: сохраненной ссылки на Entry
(или StringVar
для него, но в этом случае это не обязательно), привязки для клавиши Enter ифункция, которая делает все, что вы хотите сделать с содержимым этого виджета.
Измените эту строку, которая создает виджет Entry
, но не предоставляет ссылки на него:
Entry(root, textvariable=userin, fg='lime', bg='black').grid()
к этому:
e = Entry(root, textvariable=userin, fg='lime', bg='black')
e.grid()
def process(event=None):
content = e.get() # get the contents of the entry widget
print(content) # for example
# bind enter key (called return in tkinter) to the entry widget and
# connect it to the process function
e.bind('<Return>', process)