QFileDialog and German umlaut in transit

I am working on a project that I am developing using Python and PyQT4. I stumbled upon a somewhat strange QFileDialog behavior that does not occur when starting a project inside my IDE (Eclipse).

The problem is that QFileDialog in ExistingFiles mode does not return a list of selected files, when one of the file paths contains German umlauts (ä, ü, ö, etc.), QFileDialog does not offer parameters or parameters to make this reasonable in regarding this scenario. Does anyone have any ideas how to solve this?

edit: my deployment scenario, in which the error occurs, is as follows. I create an executable with Py2Exe and then make it redistributable using Inno Setup. I don’t know if this could cause a problem, but the more information, the better I think.

edit2: I do not have the exact code available until Friday, but we have an if-statement waiting for the dialog to complete. eg:

fileDialog = QFileDialog(...)
if fileDialog.exec_():
    # get the choosen files
    fileNames = fileDialog.getSelectedFiles()
    # test if if-statement is entered
    print fileNames
    # convert from QStringList to normal list of Strings
    fileNames = list(map(lambda x: str(x), fileNames))
    # to suffice as an example print each
    for fileName in fileNames:
        print fileName

The first print command is executed, the second is not. It is as if something between them does not want to stop, and Python handles the exception somehow quietly. However, QFileDialog closes as expected after selecting files and clicking Open or double-clicking on the file.

+3
source share
2 answers
  • lambda x: x.toUtf8() toLocal8Bit() TextCodec , , . python. str() QString, charmap.

  • getSelectedFiles()? Qt 4.5 QFileDialog. , - Qt, selectedFiles() .

  • QFileDialog :

    getExistingDirectory() GetOpenFileName() getOpenFileNames() GetSaveFileName()

?

0

unicode() ( str()) QString Unicode Python.

0

Source: https://habr.com/ru/post/1740006/


All Articles