Nameless
Nameless

Reputation: 403

What's the difference between Tk() and tk?

For example:

window = tk.Tk()

And,

root = Tk()

I'm somehow confused.

Upvotes: 0

Views: 1159

Answers (1)

Boomer
Boomer

Reputation: 479

This is dependent on how you're importing and if you're importing only specific components from a module or the entire module.

To more specifically address your question, tk is the name you have given the module, and Tk() is the class inside that module that you are instantiating.

Read more in the Official Docs

import tkinter as tk
window = tk.Tk()
from tkinter import Tk
window = Tk()

Upvotes: 3

Related Questions