简体   繁体   English

python 错误使用 tkinter 根未定义

[英]python error using tkinter root is not defined

I am trying to use tkinter in python.我正在尝试在 python 中使用 tkinter。

I imported tkinter using from tkinter import TK and I defined root root = TK()我使用from tkinter import TK导入了 tkinter 并定义了 root root = TK()

I use python-3 and I work on a Linux ubuntu I also did install tkinter but it keeps giving me following error:我使用 python-3 并且在 Linux ubuntu 上工作,我也确实安装了 tkinter 但它一直给我以下错误:

这是错误的屏幕截图

I am not too experienced with python yet.我对 python 还不太熟悉。 Please help me.请帮我。

The better way is to use this one import tkinter as tk instead of from tkinter import TK更好的方法是使用这个import tkinter as tk而不是 from tkinter import TK

like this image.像这张图片。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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