, когда я пытаюсь получить функцию из другого класса [Excute Secon dry PyQt5Window], появляется следующая ошибка - т.е. то есть: когда вызов метода copy_action из класса MainApp для использования в классе Uploud_Files показывает, что произошла эта ошибка:
Traceback (most recent call last):
File "index.py", line 75, in Apply
self.mainapp.copy_action()
File "index.py", line 333, in copy_action
original_pathes =self.dialog.original_path(self)
RuntimeError: super-class __init__() of type MainApp was never called
класс Uploud_Files
class Uploud_Files(QMainWindow,uploud_files):
def __init__(self, parent=None):
super(Uploud_Files, self).__init__(parent)
QMainWindow.__init__(self)
self.setupUi(self)
self.Handle_Buttoms()
self.UI_Changes()
self.mainapp=MainApp(self,init_or_dont=0)####Here to access MainApp Class
def Handle_Buttoms(self):
self.pushButton_2.setCheckable(True)
self.pushButton_2.clicked.connect(self.uploud)
self.pushButton_3.clicked.connect(self.Apply)
def UI_Changes(self):
header = self.tableWidget.horizontalHeader()
header.setSectionResizeMode(0,QHeaderView.ResizeToContents)
header.setSectionResizeMode(1,QHeaderView.ResizeToContents)
def uploud(self):
try:
global original
fileNames = QFileDialog.getOpenFileNames(self, 'uploud Images', '.', 'All Files (*.*)')
original = fileNames[0]
except Exception:
pass
self.tableWidget.setRowCount(0)
try:
orignal_filename_path = [(path, os.path.basename(path)) for path in original]
data = orignal_filename_path
for row, form in enumerate(data):
row_position = self.tableWidget.rowCount()
self.tableWidget.insertRow(row_position)
for col, item in enumerate(form):
self.tableWidget.setItem(row, col, QTableWidgetItem(str(item)))
col += 1
except Exception:
pass
def original_path(self):
if self.pushButton_2.isChecked():
global original
return original
else:
original = 0
return original
def Apply(self):
QMessageBox.information(self, 'Note', 'Please Press Create Visit')
self.close()
self.mainapp.copy_action() # Error Happend Here
часть класса MainApp
class MainApp(QMainWindow , ui):
def __init__(self , parent=None ,init_or_dont=1):
self.init_or_dont = init_or_dont
if self.init_or_dont:
super(MainApp, self).__init__(parent)
QMainWindow.__init__(self)
self.setupUi(self)
self.UI_Changes()
self.Connect_DB()
self.dialog = Uploud_Files(self) # its working When call uploud_Files Class
def copy_action(self):
original_pathes =self.dialog.original_path(self) # its working When call uploud_Files Class