I am using tkinter simpledialog.askinteger in Python and it is working beautifully, but I would like to change the command associated with the “Cancel” button. I have looked at the Python documentation on this command, found here: https://docs.python.org/3/library/dialog.html
However, all it says is that you can override the button commands; it does not provide instruction on how one would go about doing that. I am rather new to Python, so I am afraid I need it spelled out a little more explicitly.
The relevant code, when simplified, looks something like this:
while writechoice == True:
P1Cont = simpledialog.askinteger('Priority Level', 'Which priority level would you like to view?')
[This code produces a dialog box that looks like this] (https://i.sstatic.net/TMjsw63J.png)
I would really like to override the command for the ‘Cancel’ button so that it breaks out of the while loop instead of just closing the window.
Is this possible? I see a lot of answers on Stack talking about buttons in a custom tkinter popup, but not specifically within the simpledialog.