0

openfiledialog を開いた状態でディレクトリを変更する方法を教えてください。特定のディレクトリに設定したいです。

def OnOpen(self,event):
        """Open a file"""
        openFileDialog = wx.FileDialog(self,"Open log file","","","Log files (*.log)|*.log",wx.FD_OPEN | wx.FD_FILE_MUST_EXIST |wx.FD_CHANGE_DIR)

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

        input_stream = wx.FileInputStream(openFileDialog.GetPath())

        if not input_stream.IsOk():
            wx.LogError("Cannot open file '%s'."%openFileDialog.GetPath())
            return 

setdirectory などの関数を見たことがありますが、そのパラメータをどこに適用すればよいかわかりません。

4

1 に答える 1

0

のデフォルト ディレクトリは、作成FileDialog 後、表示されるに設定する必要があります。

def OnOpen(self,event):
        """Open a file"""
        openFileDialog = wx.FileDialog(self,"Open log file","","","Log files (*.log)|*.log",wx.FD_OPEN | wx.FD_FILE_MUST_EXIST |wx.FD_CHANGE_DIR)

        openFileDialog.SetDirectory(some_dir)

        if openFileDialog.ShowModal() == wx.ID_CANCEL:
            return
        ...
于 2013-11-09T06:48:18.247 に答える