[pygtk] Microsoft Windows pygtk: gtk.FileChooserDialog returns weird characters when opening cyrillic filepath
Timo
timomlists at gmail.com
Thu Jan 24 19:38:15 WST 2013
Op 23-01-13 18:52, Giuseppe Penone schreef:
> Hi,
>
> while I have a file named *E:\SOFTWARE\Кириллица.ctb* on my pc,
> selecting it with a gtk.FileChooserDialog
> and printing to terminal returns weird characters
> *E:\SOFTWARE\ÐsиÑ?иллиÑ┼а.ctb*.
Ah the joy of encodings on Windows. This is the piece of code I use
(trimmed):
class _FileChooser(gtk.FileChooser):
def get_filename(self):
filename = gtk.FileChooser.get_filename(self)
if filename is not None:
return unicode(filename)
def get_current_folder(self):
return unicode(gtk.FileChooser.get_current_folder(self))
And then subclass the above when creating a FileChooserDialog or
FileChooserButton, like so:
class MyFileChooserDialog(gtk.FileChooserDialog, _FileChooser):
def __init__(self):
super(MyFileChooserDialog, self).__init__()
class MyFileChooserButton(gtk.FileChooserButton, _FileChooser):
def __init__(self):
super(MyFileChooserButton, self).__init__("")
You can do fun things this way, but the most important thing is the
unicode conversion ofcourse.
Timo
>
> Does anybody have a clue of the reason?
> PS I have all my files starting with *# -*- coding: UTF-8 -*-*
>
> Regards,
> Giuseppe.
>
>
> _______________________________________________
> pygtk mailing list pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/
More information about the pygtk
mailing list