0

I've been coding a text editor, and it has the function to change the default font displayed in the wx.stc.SyledTextCtrl.

I would like to be able to save the font as a user preference, and I have so far been unable to save it.

The exact object type is <class 'wx._core.Font'>.

Would anyone know how to pickle/save this?

Legorooj
  • 2,646
  • 2
  • 15
  • 35

1 Answers1

1

Probably due to its nature, you cannot pickle a wx.Font.
Your remaining option is to store its constituent parts.
Personally, I store facename, point size, weight, slant, underline, text colour and background colour.
How you store them is your own decision.
I use 2 different options depending on the code.

  • Store the entries in an sqlite3 database, which allows for multiple indexed entries.
  • Store the entries in an .ini file using configobj

Both sqlite3 and configobj are available in the standard python libraries.

Rolf of Saxony
  • 21,661
  • 5
  • 39
  • 60