Reputation: 15
I have a process that runs in the background using pythonw (.pyw instead of .py) to not show console. as I am reformatting said process for distribution I need it to preform some first run questions that need answering. making the user fill out a generated text file would work but is not user friendly. it is sadly not as simple as
config = {}
config['user'] = input('new user data: ')
because there is no console to request the input it will hang unanswered
as I am tying to make this for systems that may not have custom modules I'm trying to not make dependencies. any good way to ask multiple questions without the console to host the input using the base python install.
Upvotes: 1
Views: 1480
Reputation: 414179
To emulate builtin input()
using tkinter
, you could use askstring()
:
from tkinter import Tk
from tkinter.simpledialog import askstring
root = Tk()
root.withdraw() # hide main window
config = {}
config['user'] = askstring("Title", 'new user data: ')
Upvotes: 2