Reputation: 5
I need some help over here!
import tkinter as tk
class CountVisitors:
def __int__(self, master):
self.master = master
self.button1 = tk.Button(self.master, text="Count", command=self.counting)
self.button1.pack(side=tk.LEFT)
self.button_click = 0
def counting(self):
self.button_click += 1
print(self.button_click)
def main():
root = tk.Tk()
CountVisitors(root)
root.mainloop()
if __name__ == "__main__":
main()
when I try to run this code, it prompts me an error message:
Traceback (most recent call last):
File "C:/Users/Anson/PycharmProjects/improvement/improvement.py", line 26, in <module> main()
File "C:/Users/Anson/PycharmProjects/improvement/improvement.py", line 21, in main CountVisitors(root)
TypeError: object() takes no parameters
What does it mean?
Upvotes: 0
Views: 52
Reputation: 2640
Your __init__
is misspelled (missing an 'i').
change the line:
def __int__(self, master):
to:
def __init__(self, master):
Upvotes: 2