我在使用 pickle 加载序列化数据的 MainWindow 时遇到问题。
只是一个简单的主窗口
class MainWindow(QtWidgets.QMainWindow, UI.MainUI.Ui_MainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.setupUi(self)
self.action_save.triggered.connect(self.save)
self.action_load.triggered.connect(self.load)
def save(self):
with open("Save", "wb") as f:
pickle.dump(self.test, f)
def load(self):
with open("Save", "rb") as f:
self.test = pickle.load(f)
def go(self):
self.test = Test(14)
class Test():
def __init__(self, a):
self.a = a
即使我确实调用了 MainWindow 的 super,但由于发生运行时错误,我无法进行保存:
self.test = pickle.load(f)
RuntimeError: super-class __init__() of type MainWindow was never called