I have a tkinter script, which runs just fine in IDLE. However, when I double click the .py-file from Windows Explorer, the console window flashes half a second and then it exits.
I was able to screenprint the console window. It says:
...etc.etc...
NameError: global name 'simpledialog' is not defined
simpledialog
is a module in tkinter
which I use in my script. As I do from tkinter import *
, there is no need to explicitly write tkinter.simpledialog
.
It works in IDLE, why not as .py?
IDLE uses Tkinter as its graphical environment. It is possible that your code is relying on a side effect of an import by IDLE itself. This is especially true if you use IDLE without a subprocess.
The simpledialog
module does not import when using from tkinter import *
.
Try adding this to your code:
import tkinter.simpledialog as simpledialog