0

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.

1
  • You never pass anything to Third: Third() Commented Oct 23, 2018 at 20:32

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.