M
M
Mikhail Lebedev2020-07-01 14:38:50
Python
Mikhail Lebedev, 2020-07-01 14:38:50

Why is "from tkinter import *" not importing everything?

from tkinter import *
why else is it necessary to import separately from tkinter -> ttk eg:
from tkinter import ttk

just trying to understand

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Miit, 2020-07-01
@zaza41rus

Because when importing , the __init__.py file is triggered , which already contains what will be imported. And ttk is a separate submodule that you need to import yourself

S
Sergey Karbivnichy, 2020-07-01
@hottabxp

from tkinter import *- you can't do that. Because there can be conflicts when different packages have different classes and methods with the same name.
Great example - How to insert a picture?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question