def __load_tests_from_files(self, evt): folder = self.__get_safe_path_from_root_folder(RootFolder.TESTS_FOLDER) if folder: dialog = FileDialog(self, defaultDir=folder, style=FD_OPEN | FD_FILE_MUST_EXIST | FD_MULTIPLE, wildcard=u'*.py') if dialog.ShowModal() == ID_OK: self.__load_tests_to_tree(file_paths=dialog.GetPaths()) else: show_dialog_path_doesnt_exist(self, folder)
def OnAdd(self, event): ''' dialog = AddDialog("Add Option", None) if dialog.ShowModal() == wx.ID_OK: print dialog.GetOption() self.listCtrl.AppendAndEnsureVisible(dialog.GetOption()) ''' wildcard = "All Files (*.*) | *.* |" \ "source (*.py) | *.py |" \ "Doc Files (*.doc) | *.doc" dialog = FileDialog(self, "Attach files", os.getcwd(), "", "*.*", FileDialog.OPEN | FileDialog.MULTIPLE) if dialog.ShowModal() == wx.ID_OK: fullList = dialog.GetPaths() self.attachments.copy(fullList) for item in self.attachments.GetFilenames(): self.listCtrl.Append(item) dialog.Destroy()
def loadFile(self, filename: str = ""): """ Load the specified filename; This is externally available so that we can open a file from the command line Args: filename: Its name """ # Make a list to be compatible with multi-files loading fileNames = [filename] currentDir: str = self._mediator.getCurrentDir() # TODO This is bad practice to do something different based on input if filename == "": dlg = FileDialog(self._parent, _("Choose a file"), currentDir, "", "*.put", FD_OPEN | FD_MULTIPLE) if dlg.ShowModal() != ID_OK: dlg.Destroy() return False fileNames = dlg.GetPaths() self._currentDirectoryHandler.currentDirectory = fileNames[0] dlg.Destroy() self.logger.info(f"loading file(s) {filename}") # Open the specified files for filename in fileNames: try: if self._treeNotebookHandler.openFile(filename): # Add to last opened files list self._preferences.addNewLastOpenedFilesEntry(filename) self.setLastOpenedFilesItems() self._mediator.updateTitle() except (ValueError, Exception) as e: PyutUtils.displayError(_("An error occurred while loading the project !")) self.logger.error(f'{e}')
def _loadFile(self, filename=""): """ Load the specified filename Args: filename: Its name """ # Make a list to be compatible with multi-files loading fileNames = [filename] # Ask which filename to load ? if filename == "": dlg = FileDialog(self, _("Choose a file"), self._lastDir, "", "*.put", FD_OPEN | FD_MULTIPLE) if dlg.ShowModal() != ID_OK: dlg.Destroy() return False self.updateCurrentDir(dlg.GetPath()) fileNames = dlg.GetPaths() dlg.Destroy() self.logger.info(f"loading file(s) {filename}") # Open the specified files for filename in fileNames: try: if self._mainFileHandlingUI.openFile(filename): # Add to last opened files list self._prefs.addNewLastOpenedFilesEntry(filename) self.__setLastOpenedFilesItems() self._ctrl.updateTitle() except (ValueError, Exception) as e: PyutUtils.displayError( _("An error occurred while loading the project !"), parent=self) self.logger.error(f'{e}')