openfile .nc和.txt以及其他使用wxpython

问题描述 投票:1回答:1

我在我的代码中使用openfile我需要打开nectcdf4文件和txt文件如何在我的代码中添加它:

 def onOpen(self, event):
        wildcard = "netCDF4 files (*.nc)|*.nc" #here need add .TXT 
        dialog = wx.FileDialog(self, "Open netCDF4", wildcard=wildcard,
                               style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)

        if dialog.ShowModal() == wx.ID_CANCEL:
            return


        path = dialog.GetPath()

我使用wxpython for python3.6

感谢帮助

python-3.x wxpython openfiledialog
1个回答
2
投票

您可以添加一个分号,然后添加另一个通配符字符串,例如

"Audio|*.mp3;*.wav;*.flac;*.ogg;*.dss;*.aac;*.wma;*.au;*.ra;*.dts;*.aif"

这对于创建相关文件组很有用

要么

添加另一个管道字符|和新的通配符描述和定义,例如:

wildcard ="netCDF4 files (nc)|*.nc| Text files (txt) |*.txt| All files |*.*"
© www.soinside.com 2019 - 2024. All rights reserved.