Python Forum

Full Version: Tkinter Python: How to make sure tkSimpleDialog takes in No value entered
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am making a GUI in Python 2.7 and I am using Tkinter. Right now what this simple dialog box is doing is it is taking the answer that we are typing except for '', i.e if I erase with my keyboard delete key whatever I entered into the dialog box and click close and reopen that dialog box it still remembers the text I deleted. I want it to enter '' so basically nothing after I delete everything.
answer = tkSimpleDialog.askstring("Input", "Enter the value:", parent = top, initialvalue=Address[n])
python 2.7 was obsoleted January 1, 2020.
Why are you trying to use it?
By close, you're referring to the window close "x" on the dialog box?

If so, what do you mean by "reopen" the dialog? How are you reopening it except by making another askstring() call?
When it is created you are using the option initialvalue=Address[n] so whatever Address[n] is will appear.
Either remove the option so the defualt empty string appears or change the value of Address[n] to answer