1

開いているダイアログで、ファイルをフィルター処理する*.spectrumか、フィルター処理しないようにします ( *.* all files)。

.spectrumまた、保存時に保存ダイアログに拡張機能を提案してもらいたいです。上書きするために強調表示されているnew file.extコモン。new file


両方のオプションを設定しwildcard = "*.spectrum"ましたが、より完全な解決策を教えてください。

4

1 に答える 1

1

私はこのテーマについていくつかの記事を書きました:

基本的に、開くダイアログと保存するダイアログに必要なものは次のようなものです。

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()

注: コードは私のブログから直接取得し、わずかに変更しただけです。

于 2012-06-25T14:38:11.810 に答える