【问题标题】:How to choose a file without any extension in an open file dialog in wxPython?如何在 wxPython 的打开文件对话框中选择没有任何扩展名的文件?
【发布时间】:2012-08-06 12:34:30
【问题描述】:

使用 sampleTextEditor 中的这个示例,在浏览时我可以看到并且可以打开任何带有扩展名的文件 (.)。如何打开没有扩展名的文件?

def defaultFileDialogOptions(self):
    ''' Return a dictionary with file dialog options that can be
        used in both the save file dialog as well as in the open
        file dialog. '''
    return dict(message='Choose a file', defaultDir=self.dirname,
                wildcard='*.*')

def askUserForFilename(self, **dialogOptions):
        dialog = wx.FileDialog(self, **dialogOptions)
        if dialog.ShowModal() == wx.ID_OK:
            userProvidedFilename = True
            self.filename = dialog.GetFilename()
            self.dirname = dialog.GetDirectory()
            self.SetTitle() # Update the window title with the new filename
        else:
            userProvidedFilename = False
        dialog.Destroy()
        return userProvidedFilename

【问题讨论】:

    标签: python wxpython openfiledialog


    【解决方案1】:

    *.* 更改为*

    所以现在整个文件名都在通配符下,不需要点

    【讨论】:

      猜你喜欢
      • 2014-04-10
      • 1970-01-01
      • 1970-01-01
      • 2012-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多