This is because the tkinter module tkinter not have a geometry function. These are instances of Tk .
Here is a good way to accomplish what you are trying to do:
import tkinter as TK
Why from tkinter import * is an imperfect way to import tkinter
Aside, who told you that from tkinter import * was a bad idea was right - when you do this, you load the entire tkinter namespace into the namespace of your module.
If you do this, you may encounter unpleasant namespace conflicts, for example:
from tkinter import * gui = Tk() Label = "hello" Label1 = Label(gui, text=Label)
You have rewritten the link to the tkinter Label widget so that you can no longer create shortcuts! Of course, you should not be obsessed with such local variables as anyway, but why worry about avoiding these namespace problems when you can do this:
import tkinter as TK
This import method ^^^^ is also preferable, because if at some point you want to exchange Tkinter for another module with a similar implementation, instead of combing your code for all elements of the Tkinter module, you can just go for example:
And you are all set. Or, if you want to use another module that has the same names for its classes and methods, the following will lead to chaos:
from tkinter import * from evilOverlappingModule import *
but it will be good:
import tkinter as TK import evilOverlappingModule as evil
source share