Skip to content
Advertisement

Why can’t I access tkinter objects after importing tkinter as something?

I’m following a simple tutorial, learning about the tkinter library. In the tutorial, they do this:

JavaScript

I was told the above is not good practice so instead I did:

JavaScript

However, later on in the code I have to do something like this:

JavaScript

This gives me an error because I didn’t import ttk as its own module. I would assume something like this should work:

JavaScript

yet it also gives me an error. How do I access the ttk module if tk.ttk.Frame is not the way to do it?

Advertisement

Answer

ttk is not a part of the tkinter module, it is a different file in the tkinter.

In order to import ttk you have to do this

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement