如何在搁置商店中共享tkinter小部件?

发布于 2025-02-11 04:50:46 字数 207 浏览 2 评论 0原文

是否可以使用货架模块共享TKINTER小部件?

例如:

from tkinter import *
import shelve

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灯角 2025-02-18 04:50:46

我认为它不会起作用。来自搁架文档:

“架子”是一个持久的,词典般的对象。与“ DBM”数据库的区别在于,架子中的值(不是键!)可以是任意的python对象 - 泡菜模块可以处理的任何东西。

您无法用泡菜存储tkinter对象。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文