JPeroutek JPeroutek - 7 months ago 21
Python Question

Tkinter NameError only when running script from shell

I've got a Tkinter Python program, a reduced version of which can be found below:

from tkinter import *
from tkinter.ttk import *


When I run this script from IDLE, I do not get any errors.

However, when run from PowerShell, using
I get

NameError: could not find name 'filedialog'

Windows 10 x64 on a mid-2012 MacBook Pro


IDLE is probably importing it already, but in general since filedialog is a tkinter module it won't get imported with the bare:

from tkinter import *

Include an extra:

from tkinter import filedialog

and you should be good to go.