How to share tkinter widget in a shelve store?

39 Views Asked by At

Is it possible to share a Tkinter widget using the shelve module?

For example:

from tkinter import *
import shelve

tk = Tk()
with shelve.open("store") as holder:
  holder["tk"] = tk
1

There are 1 best solutions below

0
Bryan Oakley On

I don't think it will work. From the shelve documentation:

A “shelf” is a persistent, dictionary-like object. The difference with “dbm” databases is that the values (not the keys!) in a shelf can be essentially arbitrary Python objects — anything that the pickle module can handle.

You can't store tkinter objects with pickle.