在pyqt5中的Pickle.load

时间:2014-01-08 02:13:37

标签: python python-3.x pyqt pyqt5

我使用pickle加载序列化数据时遇到MainWindow问题 只是一个简单的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

0 个答案:

没有答案