模块'tkinter'在python 3.5中没有属性'Tk' [英] module 'tkinter' has no attribute 'Tk' with python 3.5

查看:37
本文介绍了模块'tkinter'在python 3.5中没有属性'Tk'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

启动我的程序时,我看到了这个错误:模块‘tkinter’没有属性‘Tk’".因此,我将程序名称从tkinter.py"更改为tkinterrr.py",但我也收到了该错误.我能做什么?

Launching my program i visualized this error: "module 'tkinter' has no attribute 'Tk'". So I changed the name of my program from "tkinter.py" to "tkinterrr.py" but I obtain that error as well. What can I do?

代码如下:

import tkinter as tk


LARGE_FONT = ("Verdana", 12)


class SeaofBTCapp(tk.Tk):

    def __init__(self, *args, **kwargs): #args all var, kwargs all dict

        tk.Tk.__init__(self, *args, **kwargs)
        container = Tk.Frame(self) #frame hedge window

        container.pack(side="top", fill="both", expand=True)

        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        self.frames = {}

        frame = StartPage(container, self)

        self.frames[StartPage] = frame

        frame.grid(row=0, column=0, sticky="nsew") #you specify all grid

        self.show_frame(StartPage)

    def show_frame(self, cont):

        frame = self.frames[cont] # key
        frame.tkraise()

class StartPage(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        label = tk.Label(self, text="Start Page", font=LARGE_FONT) #Label class label object
        label.pack(pady=10, padx=10)

app = SeaofBTCapp()
app.mainloop()

推荐答案

好的我解决了...我没有从目录中删除旧的tkinter.py"文件!

Ok I solved... I didn't delete the old "tkinter.py" file from the directory!

这篇关于模块'tkinter'在python 3.5中没有属性'Tk'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆