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@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to