Python Forum
[Tkinter] Meaning
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Meaning
#1
Since python is very confusing and much of the syntax is kicking my butt, what does "import tkinter as tk" and "root= tk.Tk()" mean?
Reply
#2
Okay if you need help with Python come to a free online classroom and get continuous interactive help

As for your particular issue

import tkinter as tk this simply says import the tkinter library and as an internal reference we will be using tk instead of tkinter

so instead of tkinter.TK() where we use the library name to reference one of its methods we use the shorthand version of tk.TK()

as for root = tk.TK() you are assigning to root the value return from the call to tk.TK() method if you do not now what the Tkinter TK() method returns you would want to consult the Tkinter library documentation as that has nothing to do with python directly
Reply
#3
Thanks for the info. I've come to the conclusion that since I'm using Pydroid3 on my android tablet, much of the code I try doesn't execute correctly. I have Anaconda/Spyder on my windows 10 and have very few errors. I'll try the classroom.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020