[PyKDE] Pickle with QT

Eron Lloyd eronlloyd at gmail.com
Tue Mar 21 22:31:08 GMT 2006


I believe Python doesn't allow wrapped objects to be pickled; in other
words, if your class inherits from any Qt class, you'll need to look
at other serialization solutions.

Eron

On 3/21/06, Maxwell Bottiger <sleepylight at gmail.com> wrote:
> Hey all,
>
> I wanted to make a really simple save/load procedure for my Qt application.
> I was hoping I could use pickle to capture the state of my whole class and
> write it out, but whenever I try this I get a seg fault in sip.  I'll show
> the backtrace and some of the code below.  This is my first try so any
> pointers (no pun intended) would be appreciated.
>
> ------------------------------------------CODE
> from qt import *
> from dasrtconfig import *
> import sys
> from os import path
> import pickle
>
> class DasrtFunc(DASRTConfigForm):
>     def __init__(self, *args):
>         apply(DASRTConfigForm.__init__, (self, ) + args) #call Form2 init
> and pass args
>
>     def saveConfig(self):
>         outfile = file("out.txt", "w")
>         pickle.dump(self, outfile)
>         outfile.close()
>
> if __name__ == "__main__":
>    app = QApplication(sys.argv)
>    f = DasrtFunc()
>    f.show()
>    app.setMainWidget(f)
>    app.exec_loop()
>
> ---------------------------------------BackTrace
> #0  0x001e9ffc in initsip () from
> /usr/lib/python2.4/site-packages/sip.so
> #1  0x00393f6f in PyType_IsSubtype () from /usr/lib/libpython2.4.so.1.0
> #2  0x0035d3b4 in PyObject_Call () from /usr/lib/libpython2.4.so.1.0
> #3  0x003babde in PyEval_EvalFrame () from /usr/lib/libpython2.4.so.1.0
> #4  0x003bcef8 in PyEval_EvalCodeEx () from /usr/lib/libpython2.4.so.1.0
> #5  0x00371be1 in PyFunction_SetClosure () from /usr/lib/libpython2.4.so.1.0
> #6  0x0035d3b4 in PyObject_Call () from /usr/lib/libpython2.4.so.1.0
> #7  0x003b61c0 in PyEval_CallObjectWithKeywords ()
>    from /usr/lib/libpython2.4.so.1.0
> #8  0x003d7901 in PyEval_CallMethod () from /usr/lib/libpython2.4.so.1.0
> #9  0x00396093 in _PyType_Lookup () from /usr/lib/libpython2.4.so.1.0
> #10 0x003831f3 in PyCFunction_Call () from /usr/lib/libpython2.4.so.1.0
> #11 0x003bc092 in PyEval_EvalFrame () from /usr/lib/libpython2.4.so.1.0
> #12 0x003bb7e4 in PyEval_EvalFrame () from /usr/lib/libpython2.4.so.1.0
> #13 0x003bb7e4 in PyEval_EvalFrame () from /usr/lib/libpython2.4.so.1.0
> #14 0x003bcef8 in PyEval_EvalCodeEx () from /usr/lib/libpython2.4.so.1.0
> #15 0x003bb69c in PyEval_EvalFrame () from /usr/lib/libpython2.4.so.1.0
> #16 0x003bcef8 in PyEval_EvalCodeEx () from /usr/lib/libpython2.4.so.1.0
> #17 0x00371be1 in PyFunction_SetClosure () from /usr/lib/libpython2.4.so.1.0
> #18 0x0035d3b4 in PyObject_Call () from /usr/lib/libpython2.4.so.1.0
> #19 0x00364c76 in PyMethod_Fini () from /usr/lib/libpython2.4.so.1.0
> #20 0x0035d3b4 in PyObject_Call () from /usr/lib/libpython2.4.so.1.0
> #21 0x003b61c0 in PyEval_CallObjectWithKeywords ()
>
>
> _______________________________________________
> PyKDE mailing list    PyKDE at mats.imk.fraunhofer.de
> http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
>
>
>




More information about the PyQt mailing list