当前位置: 动力学知识库 > 问答 > 编程问答 >

module 'tkinter' has no attribute 'Tk' with python 3.5

问题描述:

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?

That's the code:

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

网友答案:

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

分享给朋友:
您可能感兴趣的文章:
随机阅读: