views:

48

answers:

0

The Error:

Traceback (most recent call last):
File "<string>", line 244, in run_nodebug
File "C:\Python26\pickleexample.py", line 13, in <module>
place = cPickle.load(f)
cPickle.UnpicklingError: NEWOBJ class argument has NULL tp_new

My Code:

import Tkinter
import cPickle

root = Tkinter.Tk()
place = 0
root.place = Tkinter.IntVar()
root.sclX = Tkinter.Scale(root, from_=0, to=1500, orient='horizontal', resolution=1,
                          variable=root.place)
root.sclX.pack(ipadx=75)

try:
    with open('myconfig.pk', 'rb') as f:
        place = cPickle.load(f)
except IOError:
    pass
else:
    root.place.set(place)


def tracer(*a):
    global place
    place = root.place.get()
root.place.trace('r', tracer)


root.resizable(False, False)
root.title('Scale')
root.mainloop()


with open('myconfig.pk', 'wb') as f:
    cPickle.dump(place, f, -1);