開いているダイアログで、ファイルをフィルター処理する*.spectrum
か、フィルター処理しないようにします ( *.* all files
)。
.spectrum
また、保存時に保存ダイアログに拡張機能を提案してもらいたいです。上書きするために強調表示されているnew file.ext
コモン。new file
両方のオプションを設定しwildcard = "*.spectrum"
ましたが、より完全な解決策を教えてください。
私はこのテーマについていくつかの記事を書きました:
基本的に、開くダイアログと保存するダイアログに必要なものは次のようなものです。
wildcard = "Python source (*.spectrum)|*.spectrum|" \
"All files (*.*)|*.*"
次に、コードで次のようにします。
def onOpenFile(self, event):
"""
Create and show the Open FileDialog
"""
dlg = wx.FileDialog(
self, message="Choose a file",
defaultDir=self.currentDirectory,
defaultFile="",
wildcard=wildcard,
style=wx.OPEN | wx.MULTIPLE | wx.CHANGE_DIR
)
if dlg.ShowModal() == wx.ID_OK:
paths = dlg.GetPaths()
print "You chose the following file(s):"
for path in paths:
print path
dlg.Destroy()
#----------------------------------------------------------------------
def onSaveFile(self, event):
"""
Create and show the Save FileDialog
"""
dlg = wx.FileDialog(
self, message="Save file as ...",
defaultDir=self.currentDirectory,
defaultFile="", wildcard=wildcard, style=wx.SAVE
)
if dlg.ShowModal() == wx.ID_OK:
path = dlg.GetPath()
print "You chose the following filename: %s" % path
dlg.Destroy()
注: コードは私のブログから直接取得し、わずかに変更しただけです。