Python open file dialog
15 Python code examples are found related to "
open file dialog".
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: __init__.py From usdmanager with Apache License 2.0 | 6 votes |
def openFileDialog(self, path=None): """ Show the Open File dialog and open any selected files. :Parameters: path : `str` | None File path to pre-select on open """ startFilter = FILE_FILTER[self.currTab.fileFormat] fd = FileDialog(self, "Open File(s)", self.lastOpenFileDir, FILE_FILTER, startFilter, self.preferences['showHiddenFiles']) fd.setFileMode(fd.ExistingFiles) if path: fd.selectFile(path) if fd.exec_() == fd.Accepted: paths = fd.selectedFiles() if paths: self.lastOpenFileDir = QtCore.QFileInfo(paths[0]).absoluteDir().path() self.setSources(paths)
Example 2
Source File: scripts.py From securecrt-tools with Apache License 2.0 | 6 votes |
def file_open_dialog(self, title, button_label="Open", default_filename="", file_filter=""): """ Prompts the user to select a file that will be processed by the script. In SecureCRT this will give a pop-up file selection dialog window. For a direct session, the user will be prompted for the full path to a file. See the SecureCRT built-in Help at Scripting > Script Objects Reference > Dialog Object for more details. :param title: <String> Title for the File Open dialog window (Only displays in Windows) :param button_label: <String> Label for the "Open" button :param default_filename: <String> If provided a default filename, the window will open in the parent directory of the file, otherwise the current working directory will be the starting directory. :param file_filter: <String> Specifies a filter for what type of files can be selected. The format is: <Name of Filter> (*.<extension>)|*.<extension>|| For example, a filter for CSV files would be "CSV Files (*.csv)|*.csv||" or multiple filters can be used: "Text Files (*.txt)|*.txt|Log File (*.log)|*.log||" :return: The absolute path to the file that was selected :rtype: str """ pass
Example 3
Source File: dxf_import.py From PyEagle with GNU Lesser General Public License v2.1 | 5 votes |
def fileOpenDialog(self): fileDialog = QFileDialog(filter="*.dxf") fileDialog.setFileMode(QFileDialog.ExistingFile) result = fileDialog.exec_() if result: self.filePathEdit.setText(fileDialog.selectedFiles()[0]) self.readFileInfo()
Example 4
Source File: sparrow-wifi.py From sparrow-wifi with GNU General Public License v3.0 | 5 votes |
def openFileDialog(self, fileSpec="CSV Files (*.csv);;All Files (*)"): options = QFileDialog.Options() options |= QFileDialog.DontUseNativeDialog fileName, _ = QFileDialog.getOpenFileName(self,"QFileDialog.getOpenFileName()", "",fileSpec, options=options) if fileName: return fileName else: return None
Example 5
Source File: QgsManager.py From QGISFMV with GNU General Public License v3.0 | 5 votes |
def openVideoFileDialog(self): ''' Open video file dialog ''' Exts = ast.literal_eval(parser.get("FILES", "Exts")) filename, _ = askForFiles(self, QCoreApplication.translate( "ManagerDock", "Open video"), exts=Exts) if filename: _, name = os.path.split(filename) self.AddFileRowToManager(name, filename) return
Example 6
Source File: excel_ui.py From FlowCal with MIT License | 5 votes |
def show_open_file_dialog(filetypes): """ Show an open file dialog and return the path of the file selected. Parameters ---------- filetypes : list of tuples Types of file to show on the dialog. Each tuple on the list must have two elements associated with a filetype: the first element is a description, and the second is the associated extension. Returns ------- filename : str The path of the filename selected, or an empty string if no file was chosen. """ # initialize tkinter root window root = Tk() # remove main root window (will cause kernel panic on OSX if not present) root.withdraw() # link askopenfilename window to root window filename = askopenfilename(parent = root, filetypes=filetypes) # refresh root window to remove askopenfilename window root.update() return filename
Example 7
Source File: localize.py From picasso with MIT License | 5 votes |
def open_file_dialog(self): if self.pwd == []: dir = None else: dir = self.pwd path, exe = QtWidgets.QFileDialog.getOpenFileName( self, "Open image sequence", directory=dir, filter="*.raw; *.tif" ) if path: self.pwd = path self.open(path)
Example 8
Source File: gui.py From PrusaControl with GNU General Public License v3.0 | 5 votes |
def open_model_file_dialog(self): filters = "STL (*.stl *.STL)" title = "Import model file" open_at = self.settings.value("model_path", "") data = QFileDialog.getOpenFileNames(None, title, open_at, filters) if data: self.settings.setValue("model_path", QFileInfo(data[0]).absolutePath()) filenames_list = [] for path in data: filenames_list.append(self.convert_file_path_to_unicode(path)) return filenames_list
Example 9
Source File: gui.py From PrusaControl with GNU General Public License v3.0 | 5 votes |
def open_gcode_file_dialog(self): filters = "GCODE (*.gcode *.GCODE *.Gcode)" title = "Import gcode file" open_at = self.settings.value("gcode_path", "") data = QFileDialog.getOpenFileName(None, title, open_at, filters) if data: self.settings.setValue("gcode_path", QFileInfo(data).absolutePath()) return data
Example 10
Source File: gui.py From PrusaControl with GNU General Public License v3.0 | 5 votes |
def open_project_file_dialog(self): filters = "Prusa (*.prusa *.PRUSA)" title = 'Open project file' open_at = self.settings.value("project_path", "") data = QFileDialog.getOpenFileName(None, title, open_at, filters) if data: self.settings.setValue("project_path", QFileInfo(data).absolutePath()) return data
Example 11
Source File: beso_fc_gui.py From beso with GNU Lesser General Public License v3.0 | 5 votes |
def openFileNameDialog(self): options = QFileDialog.Options() options |= QFileDialog.DontUseNativeDialog inp_file, _ = QFileDialog.getOpenFileName(self, "Select file", "", "Analysis Files (*.inp);;All Files (*)", options=options) return inp_file
Example 12
Source File: ml_svm_predict.py From Pythonic with GNU General Public License v3.0 | 5 votes |
def openFileNameDialog(self, event): options = QFileDialog.Options() #options |= QFileDialog.DontUseNativeDialog fileName, _ = QFileDialog.getOpenFileName(self, QC.translate('', 'Open SVM model file'), self.home_dict,"All Files (*);;Pythonic Files (*.pyc)", options=options) if fileName: logging.debug('MLSVM_Predict::openFileNameDialog() called with filename: {}'.format(fileName)) self.filename = fileName self.filename_text.setText(self.filename)
Example 13
Source File: wizard.py From rpg with GNU General Public License v2.0 | 5 votes |
def openBuildPathFileDialog(self): brows = QFileDialog() self.getPath = brows.getExistingDirectory(self, "Select Directory", expanduser("~"), QFileDialog.ShowDirsOnly) self.buildLocationEdit.setText(self.getPath)
Example 14
Source File: open_file_dialog.py From pywebview with BSD 3-Clause "New" or "Revised" License | 5 votes |
def open_file_dialog(window): file_types = ('Image Files (*.bmp;*.jpg;*.gif)', 'All files (*.*)') result = window.create_file_dialog(webview.OPEN_DIALOG, allow_multiple=True, file_types=file_types) print(result)
Example 15
Source File: Misc.py From RMS with GNU General Public License v3.0 | 5 votes |
def openFileDialog(dir_path, initialfile, title, mpl): """ Open the file dialog and close it properly, depending on the backend used. Arguments: dir_path: [str] Initial path of the directory. initialfile: [str] Initial file to load. title: [str] Title of the file dialog window. mpl: [matplotlib instance] Instace of matplotlib import which is used to determine the used backend. Return: file_name: [str] Path to the chosen file. """ root = tkinter.Tk() root.withdraw() root.update() # Open the file dialog file_name = filedialog.askopenfilename(initialdir=dir_path, \ initialfile=initialfile, title=title) root.update() if (mpl.get_backend() != 'TkAgg') and (mpl.get_backend() != 'WXAgg'): root.quit() else: root.destroy() return file_name