method def problem

Hi,
I am just learning, not just wxPython, but programming at all. I neen application that would save everything in utf-8 and work with utf-8. How do I combine SaveFile with something like codecs.open(filename,'w','utf-8'). Or is there other way how to save file in utf-8 in wxPython.
So far I use this:

def menuSaveAs(self, event):
        dlg = wxFileDialog(self, "Save File As", ".", "", "*.*", wxSAVE)
        try:
            if dlg.ShowModal() == wxID_OK:
                filename = dlg.GetPath()
                self.txtEditor.SaveFile(filename)
                self.FileName=filename
        finally:
            dlg.Destroy()

Thanks
Simon

import codecs

(utf8_encode, utf8_decoder, utf8_reader, utf8_writer) = codecs.lookup('utf-8')

file = utf8_writer(open(path_to_file, 'w'))
file.write(unicode_string)

Derrick

Petr Šimon wrote:

···

Hi,
I am just learning, not just wxPython, but programming at all. I neen application that would save everything in utf-8 and work with utf-8. How do I combine SaveFile with something like codecs.open(filename,'w','utf-8'). Or is there other way how to save file in utf-8 in wxPython.
So far I use this:

def menuSaveAs(self, event):
       dlg = wxFileDialog(self, "Save File As", ".", "", "*.*", wxSAVE)
       try:
           if dlg.ShowModal() == wxID_OK:
               filename = dlg.GetPath()
               self.txtEditor.SaveFile(filename)
               self.FileName=filename
       finally:
           dlg.Destroy()

Thanks
Simon

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org