如何在wxPython的“打开文件”对话框中选择没有任何扩展名的文件?

2024-10-01 05:00:52 发布

您现在位置:Python中文网/ 问答频道 /正文

使用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

Tags: 文件theinselfreturndefaswith