Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
wx.lib.editor file I/O does not support unicode strings in python 3 #1193
Description of the problem:
File load/save in wx.lib.editor fails because file read/write is expecting bytes, not unicode string in python 3.
Run the following, selecting ">File >New", typing some text, then selecting ">File >Save"
app = wx.App() dlg = editor.EditorFrame() dlg.Show() app.MainLoop()
Need to convert encode/decode bytes from utf8 when working with unicode in binary files, or need to open the file as 'r' or 'w' with the encoding on the open call.
The following works in python 2.7 and 3.x for wx 4 with the EditorFrame example:
I guess the text control in wx4 accepts either
You may not want to do this change since it changes the interface to
Similarly for writing, the new version requires
BInary I/O preserves line endings, so for compatibility maybe want to specify
The best solution depends on the intricacies of newline handling in wx.TextCtrl.