Reputation: 101
I am trying to implment inheritance into my school work but it is not working. This the code which I have written, this is a basic version of it:
from tkinter import *
class First(Frame):
def __init__(self,master):
super(First,self).__init__(master)
self._x = int(input("Int: "))
class Second(Frame):
def __init__(self,master):
super(Second,self).__init__(master)
self._y = self._x + 9
class Third(First,Second):
def __init__(self,master):
super(Third,self).__init__(master)
print(self._y)
root = Tk()
root.configure(background='light grey')
myGUI = First(root)
Third()
root.mainloop()
Im trying to make it make the user input a int then +9 then print it using inheritance. But i keep getting the error:
TypeError: __init__() missing 1 required positional argument: 'master'
My code may look very messy but im new to python so apologies, thanks for help.
Upvotes: 0
Views: 34
Reputation: 385950
Like the error says, Third
requires one argument named master
. You're not passing any arguments when you do Third()
You need to call it as Third(root)
.
Upvotes: 2