Reputation: 13
I'm new to Python 3 programming and are getting errors that I can't seem to fix. I'm trying to make a text editor. This is the code:
import tkinter as tk
class PyText:
def __init__(self, master):
master.title("Untitled - PyText")
master.geometry("1200x700")
if __name__ == "__main__":
master = tk.TK()
pt = PyText(master)
master.mainloop()
Running it I get: Traceback (most recent call last): File "textEdit.py", line 12, in master = tk.TK() AttributeError: module 'tkinter' has no attribute 'TK'
How can I fix this??? Thank you for the help!
Upvotes: 0
Views: 43
Reputation: 1390
The problem is that you use tk.TK()
, but you should use tk.Tk()
, with small 'k'.
Also, you should probably use self.master
in __init__
function:
def __init__(self, master):
self.master = master
self.master.title("Untitled - PyText")
self.master.geometry("1200x700")
Then the link to a master object is preserved inside the pt
object as pt.master
.
Hope that's helpful!
Upvotes: 2