Welcome to StackOverflow!
It's considered bad practice to use *
when importing from a package, exactly because it just dumps everything from that package into your code. If two different packages have something with the same name (like in your code tkinter.Image
and PIL.Image
), you get some strange errors.
It's unfortunate that the documentation for tkinter uses from tkinter import *
as an example.
What you want is to selectively import what you need:
# Only import what you need. When imported like this, you
# use its name directly
from tkinter import TK
from tkinter import ttk
root = Tk()
If I'm calling an imported function just a couple time throughout my code, I usually import it like so as to not pollute my namespace:
import tkinter
from tkinter import ttk
# Prefix it with the package name you used to import
root = tkinter.Tk()
A pretty good tutorial on importing is
https://www.digitalocean.com/community/tutorials/how-to-import-modules-in-python-3
Cheers!