Search code examples
pythonwxpythonwxwidgets

How can I set the default file name in saveFileDialog.SetFilename in wxPython for windows?


For some reason, the following code snippet works on OS X Mavericks, but not on Windows 7:

fileLabelDefault = self.filename + ".xlsx"
saveFileDialog = wx.FileDialog(self, "Speichern", "", fileLabelDefault, 
                                   "Excel files (*.xlsx)|*.xlsx", 
                                   wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
saveFileDialog.SetFilename(fileLabelDefault)

Solution

  • I have to answer this question myself, because I just figured out the answer!

    The code above is valid. I had an invalid character / in the default filename and OS X allows this, but replaces it with a :. Windows does not do this automatically.