简体   繁体   中英

using tkinter module with python 3.6

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:)

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 somereferences 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM