Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我一直在编写一个文本编辑器,它具有更改wx.stc.SyledTextCtrl.
wx.stc.SyledTextCtrl
我希望能够将字体保存为用户偏好,但到目前为止我还无法保存它。
确切的对象类型是<class 'wx._core.Font'>.
<class 'wx._core.Font'>
有人知道如何腌制/保存这个吗?
可能由于其性质,您不能pickle使用wx.Font. 您剩下的选择是存储其组成部分。 就我个人而言,我存储面部名称、点大小、重量、倾斜度、下划线、文本颜色和背景颜色。 如何存储它们是您自己的决定。 我根据代码使用 2 个不同的选项。
pickle
wx.Font
sqlite3
.ini
configobj
两者sqlite3都configobj在标准 python 库中可用。