和pickle.load在pyqt5(Pickle.load in pyqt5)

2019-10-19 04:54发布

我用泡菜来加载序列化的数据具有与主窗口的麻烦。
只是一个简单的主窗口

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

我不能另存为,即使我叫主窗口的超级发生运行时错误发生:

self.test = pickle.load(f)
RuntimeError: super-class __init__() of type MainWindow was never called
文章来源: Pickle.load in pyqt5