简体   繁体   English

为什么我使用以下代码收到 tkinter 的导入错误?

[英]Why am I getting an importing error for tkinter with the code below?

I am a newby to python and am struggling with the basic code below.我是 python 的新手,正在为下面的基本代码苦苦挣扎。 I am uncertain why I am not getting a Tk window to open.我不确定为什么我没有打开 Tk window。 The code I have thus far is:到目前为止我的代码是:

import tkinter as tk
from tkinter import tkk 

class Application(tk.Tk):
    """Application root window"""

if __name__ == "__main__":
    app = Application()
    app.mainloop()

The error I receive back from my terminal is:我从终端收到的错误是:

ImportError: cannot import name 'tkk' from 'tkinter'
(/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/tkinter/__init__.py)

Any ideas?有任何想法吗?

Try this out instead: from tkinter import ttk .试试这个: from tkinter import ttk

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

相关问题 导入 matplotlib 时出现以下错误 - I am getting the error below while importing matplotlib 为什么我在应用此代码时收到此错误。 我在下面附上了错误和代码? - Why I am getting this error while applying this code. I have enclosed the error and code below? 为什么在下面的代码中出现“ Paramiko:读取SSH协议横幅错误”? 有什么解决方案? - Why i am getting “Paramiko : Error reading SSH protocol banner” in below code? What is the solution for it? 为什么我的输出没有? 而不是下面代码中的图像 - why am I getting output as none? and not the images in the code below 为什么在以下代码中没有得到任何输出? - Why am I not getting any output in the below code? 我在 python 代码中导入 mif,但我不断收到错误 - i am importing mifs in python code but i keep getting error 我的代码出现超出范围错误,请参阅下面的详细信息 - I am getting out of range error on code, see details below 为什么导入多处理时出现导入错误? - Why am I getting an import error upon importing multiprocessing? 为什么我在python 3.3上导入进程时出现导入错误? - Why am I getting an import error for importing process on python 3.3? 为什么在导入 AudioSegment 时出现错误? - why am i getting error when importing AudioSegment?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM