Home > database >  Emulate waiting for input() in Tkinter
Emulate waiting for input() in Tkinter

Time:05-04

I am trying to recreate a command-line application into a desktop one using Tkinter. I cannot seem to figure out how to recreate the input() function - waiting for input and pressing Enter to confirm. Has anyone had a similar issue?

I have looked into button_pressed in Tkinter. Is there a better alternative?

CodePudding user response:

You use a tkinter Text widget. Pressing "enter" should fire the "default" button, so you'll need a handler for that button, where you fetch the result. If this is something separate from your regular GUI, perhaps you want tkinter's simpledialog.askstring.

https://docs.python.org/3/library/dialog.html

  • Related