tkFileDialog and locale under Linux

Matthias Huening mhuening at zedat.fu-berlin.de
Tue Sep 23 16:44:57 CEST 2008


Hi,

I have problems using tkFileDialog under Linux (Ubuntu 8.04 in my case, but 
other Linuxes seem to show the same behaviour).

The following works fine:

import tkFileDialog
f = tkFileDialog.askopenfilename()

No problem, I can chose a filename.

But when switching the locale (in my case to German) like this:

import locale
locale.setlocale(locale.LC_ALL, '')

the file dialog won't work anymore. The traceback is:

Traceback (most recent call last):
  File "/usr/lib/python2.5/lib-tk/Tkinter.py", line 1406, in __call__
    return self.func(*args)
  File "TextSTAT.pyw", line 701, in datei_hinzu
    dateinamen = tkFileDialog.askopenfilename(initialdir=cfg['FileDir'], 
filetypes= (('All', '*.*'),('Text', '*.txt'),('HTML', '*.htm*'),('MS Word', 
'*.doc'),('MS Word 2007', '*.docx'),('OpenOffice 1.x', 
'*.sxw'),('OpenOffice 2.x', '*.odt')), multiple=1)
  File "/usr/lib/python2.5/lib-tk/tkFileDialog.py", line 125, in 
askopenfilename
    return Open(**options).show()
  File "/usr/lib/python2.5/lib-tk/tkCommonDialog.py", line 48, in show
    s = w.tk.call(self.command, *w._options(self.options))
TclError: expected floating-point number but got "0.0"


Switching back to the C-locale solves the problem:
locale.setlocale(locale.LC_ALL, 'C')

tkFileDialog will work again.

Any ideas?

Best, Matthias




More information about the Python-list mailing list