我正在設計某種pdf轉換器。它可以將圖像和其他 pdf 文件合并為一個pdf文件。我正在使用wxPythonGUI 框架。有兩個按鈕:一個用于設置輸入文件,第二個用于設置輸出文件。這是我的兩個事件處理程序。def pick_files(self, event): with wx.FileDialog(self, "Pick files", wildcard=self.load_options, style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE) as fileDialog: if fileDialog.ShowModal() != wx.ID_CANCEL: self.files_list = fileDialog.GetPaths() self.convert_and_merge_button.Enable()def convert_and_merge(self, event): with wx.FileDialog(self, "Convert and merge", wildcard=self.save_options, style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) as fileDialog: if fileDialog.ShowModal() != wx.ID_CANCEL: # pass parameters to Converter class self.converter.convert(self.files_list, fileDialog.GetPath())問題是,如果我選擇一個輸入文件作為輸出文件,程序就會崩潰。如何防止某些文件在FileDialog.我想知道是否有可能有某種類型MessageBox,比如“這個文件被設置為輸入文件。你不能覆蓋它?!?并回到FileDialog.
添加回答
舉報
0/150
提交
取消