У меня есть два класса, и я пытаюсь наследовать класс в одном файле от класса в другом. Однако моя проблема возникает, когда я пытаюсь поместить account_validation
в другой файл и унаследовать его в моем классе PageTwo
. Я подвержен ошибке:
Traceback (most recent call last):
File "C:\Users\stecd\Desktop\NEA - topLevel - client server\Frontend - Copy.py", line 1949, in <module>
customerEnd = selfService()
File "C:\Users\stecd\Desktop\NEA - topLevel - client server\Frontend - Copy.py", line 49, in __init__
self.frame = F(self.container, self)
File "C:\Users\stecd\Desktop\NEA - topLevel - client server\Frontend - Copy.py", line 91, in __init__
validation.account_validation.__init__(self)
TypeError: __init__() missing 2 required positional arguments: 'parent' and 'controller'
Мой код:
#Inheriting class from same file attempt
#file.py
class account_validation():
def __init__(self):
self.test = 'test2'
class PageTwo(tk.Frame,
validation.account_validation):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
account_validation.__init__(self)
print(self.test)
#inheriting class from another file
#validation.py
class account_validation():
def __init__(self):
self.test = 'test2'
#file.py
import validation
class PageTwo(tk.Frame, account_validation):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
account_validation.__init__(self)
print(self.test)