>From the command line I see:

 Directory di C:\Documents and Settings\giu\Documenti\TEST

23/01/2013  22.26    <DIR>          .
23/01/2013  22.26    <DIR>          ..
23/01/2013  22.22             1.395 test.py
31/10/2012  23.03           335.377 *?????????.ctd*
               2 File        336.772 byte
               2 Directory  80.310.996.992 byte disponibili

C:\Documents and Settings\giu\Documenti\TEST>python test.py
C:\Documents and Settings\giu\Documenti\TEST\*ðÜð©ÐÇð©ð╗ð╗ð©Ðåð░.ctd*

C:\Documents and Settings\giu\Documenti\TEST>chcp
Tabella codici attiva: *850*

In the file manager instead I have:

C:\Documents and Settings\giu\Documenti\TEST\test.py
C:\Documents and Settings\giu\Documenti\TEST\*Кириллица.ctd*

the code of *test.py* is:


#!/usr/bin/env python
# -*- coding: utf-8 -*-

import gtk, os

def dialog_file_select(filter_pattern=None, filter_name=None,
curr_folder=None, parent=None):
    """The Select file dialog, Returns the retrieved filepath or None"""
    chooser = gtk.FileChooserDialog(title = "Select File",
                                    action=gtk.FILE_CHOOSER_ACTION_OPEN,
                                    buttons=(gtk.STOCK_CANCEL,
gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK) )
    if parent != None:
        chooser.set_transient_for(parent)
        chooser.set_property("modal", True)
        chooser.set_property("destroy-with-parent", True)
        chooser.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
    else: chooser.set_position(gtk.WIN_POS_CENTER)
    if curr_folder == None or os.path.isdir(curr_folder) == False:
        chooser.set_current_folder(os.path.expanduser('~'))
    else:
        chooser.set_current_folder(curr_folder)
    if filter_pattern != None:
        filter = gtk.FileFilter()
        filter.set_name(filter_name)
        filter.add_pattern(filter_pattern)
        chooser.add_filter(filter)
    if chooser.run() == gtk.RESPONSE_OK:
        filepath = chooser.get_filename()
        chooser.destroy()
        return filepath
    else:
        chooser.destroy()
        return None

filepath = dialog_file_select()
print filepath
#-------------------------------------------------------------

Please help me.
Giuseppe.






On Wed, Jan 23, 2013 at 8:18 PM, Christian Mallwitz <[email protected]>wrote:

> Assuming you 'print' the filename to stdout and Python has the
> filename internally as UTF-8 string, Python may not do the right thing
> when converting the string to bytes to be processed by your console
> window. The console windows code page would be of interest too (run
> chcp).
>
> Christian
>
> On Wed, Jan 23, 2013 at 5:52 PM, Giuseppe Penone <[email protected]>
> wrote:
> > 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.
> >
> > Does anybody have a clue of the reason?
> > PS I have all my files starting with # -*- coding: UTF-8 -*-
> >
> > Regards,
> > Giuseppe.
> >
> > _______________________________________________
> > pygtk mailing list   [email protected]
> > http://www.daa.com.au/mailman/listinfo/pygtk
> > Read the PyGTK FAQ: http://faq.pygtk.org/
> _______________________________________________
> pygtk mailing list   [email protected]
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to