using tkinter module with python 3.6

Viewed 129

I'm trying to write simple things in a Tkinter module using python 3.6 in Anaconda. This is my code

from tkinter import * 
root = Tk()
thelabel = label(root, text="this is our tk window")
thelabel.pack()
root.mainloop()  

but I get the error:

TclError: can't invoke "label" command: application has been destroyed
ERROR: execution aborted

and I keep getting a blank Tkinter window whenever I run my code and I don't understand what is the problem, thanks:)

2 Answers

You have a small error...

Here is the correct way:

from tkinter import *
root = Tk()
thelabel = Label(root, text="this is our tk window")
thelabel.pack()
root.mainloop()

You should try reading a bit on tkinter.

Here are some references specifically on label.

Hope you find this helpful!

change your code to this

from tkinter import * 
root = Tk()
thelabel = Label(root, text="this is our tk window")
thelabel.pack()
root.mainloop()

Labels start with a capital L not small l it will fix your error

Related