I created my own class which is basically the same as Button
from tkinter but I want to change a few things.
I need to redefine the __init__
method so that it does everything the Button__init__
method does but I want to add some stuff like append the instance to the list of students. so I used super().__init__()
but I have no idea what goes inside of the brackets. I know the basics of inheritance from youtube tutorials but inheriting from the Button class seems more comlicated. I tried copying some stuff from the Button class from tkinter module but i still get errors. How do i fix this?
from tkinter import *
root = Tk()
class Student(Button):
students = []
def __init__(self, master=None, cnf={}, **kw):
super().__init__(master, cnf, kw)
Student.students.append(self)
enrique = Student(root, padx=30, pady=10, text="Enrique", fg="#000000", bg="#00FFFF" )
enrique.grid(row=0, column=0)
root.mainloop()
>>>TypeError: __init__() takes from 1 to 3 positional arguments but 4 were given
Button
to see what its__init__
expects? – Scott Hunter Oct 25 '20 at 12:25