Python PyQt5.QtWidgets.QFileDialog() Examples

The following are 30 code examples of PyQt5.QtWidgets.QFileDialog(). 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. You may also want to check out all available functions/classes of the module PyQt5.QtWidgets , or try the search function .
Example #1
Source File: CalibrationSettings.py    From nanovna-saver with GNU General Public License v3.0 7 votes vote down vote up
def saveCalibration(self):
        if not self.app.calibration.isCalculated:
            logger.debug("Attempted to save an uncalculated calibration.")
            self.app.showError("Cannot save an unapplied calibration state.")
            return
        filedialog = QtWidgets.QFileDialog(self)
        filedialog.setDefaultSuffix("cal")
        filedialog.setNameFilter("Calibration Files (*.cal);;All files (*.*)")
        filedialog.setAcceptMode(QtWidgets.QFileDialog.AcceptSave)
        selected = filedialog.exec()
        if selected:
            filename = filedialog.selectedFiles()[0]
        else:
            return
        if filename == "":
            logger.debug("No file name selected.")
            return
        self.app.calibration.notes = self.notes_textedit.toPlainText().splitlines()
        try:
            self.app.calibration.save(filename)
            self.app.settings.setValue("CalibrationFile", filename)
        except IOError:
            logger.error("Calibration save failed!")
            self.app.showError("Calibration save failed.") 
Example #2
Source File: simulation_menu.py    From simnibs with GNU General Public License v3.0 7 votes vote down vote up
def selectFile(self):
        if self.fname is not None and os.path.isfile(self.fname):
            eeg_cap_dir = os.path.dirname(self.fname)
        else:
            eeg_cap_dir = QtCore.QDir.currentPath()
        dialog = QtWidgets.QFileDialog(self)
        dialog.setWindowTitle('Open EEG Position file')
        dialog.setNameFilter('(*.csv)')
        dialog.setDirectory(eeg_cap_dir)
        dialog.setFileMode(QtWidgets.QFileDialog.ExistingFile)
        filename = None
        if dialog.exec_() == QtWidgets.QDialog.Accepted:
            filename = dialog.selectedFiles()
        if filename:
            self.fname = str(filename[0])
            self.group_box.lineEdit.setText(self.fname) 
Example #3
Source File: plugin.py    From eddy with GNU General Public License v3.0 6 votes vote down vote up
def selectPlugin(self):
        """
        Bring up a modal window that allows the user to choose a valid plugin archive.
        """
        path = os.path.dirname(self.pluginField.value())
        if not isPathValid(path):
            path = expandPath('~')

        dialog = QtWidgets.QFileDialog(self)
        dialog.setAcceptMode(QtWidgets.QFileDialog.AcceptOpen)
        dialog.setDirectory(path)
        dialog.setFileMode(QtWidgets.QFileDialog.ExistingFile)
        dialog.setViewMode(QtWidgets.QFileDialog.Detail)
        dialog.setNameFilters([File.Zip.value])

        if dialog.exec_() == QtWidgets.QFileDialog.Accepted:
            self.pluginField.setValue(first(dialog.selectedFiles()))
            self.confirmationBox.setEnabled(not isEmpty(self.pluginField.value())) 
Example #4
Source File: test_app.py    From CQ-editor with Apache License 2.0 6 votes vote down vote up
def main_multi(qtbot,mocker):

    mocker.patch.object(QMessageBox, 'question', return_value=QMessageBox.Yes)
    mocker.patch.object(QFileDialog, 'getSaveFileName', return_value=('out.step',''))

    win = MainWindow()
    win.show()

    qtbot.addWidget(win)
    qtbot.waitForWindowShown(win)
    
    editor = win.components['editor']
    editor.set_text(code_multi)

    debugger = win.components['debugger']
    debugger._actions['Run'][0].triggered.emit()

    return qtbot, win 
Example #5
Source File: WebEngine.py    From Jade-Application-Kit with GNU General Public License v3.0 6 votes vote down vote up
def _download_requested(self, download_item) -> None:
        """
        * If a download is requested call a save file dialog
        * :param download_item: file to be downloaded
        """
        if bindings() == "PyQt5":
            from PyQt5.QtWidgets import QFileDialog
        else:
            from PySide2.QtWidgets import QFileDialog
        dialog = QFileDialog(self)
        path = dialog.getSaveFileName(dialog, "Save File", download_item.path())

        if path[0]:
            download_item.setPath(path[0])
            print(f"downloading file to:( {download_item.path()} )")
            download_item.accept()
            self.download_item = download_item
            download_item.finished.connect(self._download_finished)
        else:
            print("Download canceled") 
Example #6
Source File: main.py    From MDT with GNU Lesser General Public License v3.0 6 votes vote down vote up
def _select_file(self):
        graphical_image_filters = [' '.join(el) for el in self._extension_filters] + ['All files (*)']

        open_file, used_filter = QFileDialog().getSaveFileName(caption='Select the output file',
                                                               filter=';;'.join(graphical_image_filters))

        if not any(open_file.endswith(el[0]) for el in self._extension_filters):
            extension_from_filter = list(filter(lambda v: ' '.join(v) == used_filter, self._extension_filters))
            if extension_from_filter:
                extension = extension_from_filter[0][0]
            else:
                extension = self._extension_filters[0][0]

            open_file += '.{}'.format(extension)

        if open_file:
            self.outputFile_box.setText(open_file)
            self._update_ok_button() 
Example #7
Source File: bap_trace.py    From bap-ida-python with MIT License 6 votes vote down vote up
def __init__(self, parent=None):
        super(TraceFileSelector, self).__init__(parent)
        box = QtWidgets.QHBoxLayout(self)
        label = MonitoringLabel('Trace &file:')
        self.is_ready = label.is_ready
        self.updated = label.updated
        box.addWidget(label)
        self.location = QtWidgets.QLineEdit('incidents')
        self.text = self.location.text
        must_exist = ExistingFileValidator()
        self.location.setValidator(must_exist)
        label.setBuddy(self.location)
        box.addWidget(self.location)
        openfile = QtWidgets.QPushButton(self)
        openfile.setIcon(self.style().standardIcon(
            QtWidgets.QStyle.SP_DialogOpenButton))
        dialog = QtWidgets.QFileDialog(self)
        openfile.clicked.connect(dialog.open)
        dialog.fileSelected.connect(self.location.setText)
        box.addWidget(openfile)
        box.addStretch(1)
        self.setLayout(box) 
Example #8
Source File: quick.py    From quick with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, *args, exists = False, file_okay = True, dir_okay= True,  **kwargs):
        super(GFileDialog, self).__init__(*args, **kwargs)
        self.setOption(QtWidgets.QFileDialog.DontUseNativeDialog, True)
        self.setLabelText(QtWidgets.QFileDialog.Accept, "Select")
        if (exists, file_okay, dir_okay) == (True, True, False):
            self.setFileMode(QtWidgets.QFileDialog.ExistingFile)
        elif (exists, file_okay, dir_okay) == (False, True, False):
            self.setFileMode(QtWidgets.QFileDialog.AnyFile)
        elif (exists, file_okay, dir_okay) == (True, False, True):
            self.setFileMode(QtWidgets.QFileDialog.Directory)
        elif (exists, file_okay, dir_okay) == (False, False, True):
            self.setFileMode(QtWidgets.QFileDialog.Directory)
        elif exists == True:
            self.setFileMode(QtWidgets.QFileDialog.ExistingFile)
            self.accept = self.accept_all
        elif exists == False:
            self.setFileMode(QtWidgets.QFileDialog.AnyFile)
            self.accept = self.accept_all 
Example #9
Source File: session.py    From eddy with GNU General Public License v3.0 6 votes vote down vote up
def doSaveAs(self):
        """
        Creates a copy of the currently open diagram.
        """
        diagram = self.mdi.activeDiagram()
        if diagram:
            dialog = QtWidgets.QFileDialog(self)
            dialog.setAcceptMode(QtWidgets.QFileDialog.AcceptSave)
            dialog.setDirectory(expandPath('~/'))
            dialog.setFileMode(QtWidgets.QFileDialog.AnyFile)
            dialog.setNameFilters(self.diagramExporterNameFilters())
            dialog.setViewMode(QtWidgets.QFileDialog.Detail)
            dialog.selectFile(diagram.name)
            dialog.selectNameFilter(File.Pdf.value)
            if dialog.exec_():
                filetype = File.valueOf(dialog.selectedNameFilter())
                worker = self.createDiagramExporter(filetype, diagram, self)
                worker.run(expandPath(first(dialog.selectedFiles()))) 
Example #10
Source File: WebEngine.py    From Jade-Application-Kit with GNU General Public License v3.0 6 votes vote down vote up
def _download_requested(self, download_item) -> None:
        """
        * If a download is requested call a save file dialog
        * :param download_item: file to be downloaded
        """
        if bindings() == "PyQt5":
            from PyQt5.QtWidgets import QFileDialog
        else:
            from PySide2.QtWidgets import QFileDialog
        dialog = QFileDialog(self)
        path = dialog.getSaveFileName(dialog, "Save File", download_item.path())

        if path[0]:
            download_item.setPath(path[0])
            print(f"downloading file to:( {download_item.path()} )")
            download_item.accept()
            self.download_item = download_item
            download_item.finished.connect(self._download_finished)
        else:
            print("Download canceled") 
Example #11
Source File: session.py    From eddy with GNU General Public License v3.0 6 votes vote down vote up
def doExport(self):
        """
        Export the current project.
        """
        if not self.project.isEmpty():
            dialog = QtWidgets.QFileDialog(self)
            dialog.setAcceptMode(QtWidgets.QFileDialog.AcceptSave)
            dialog.setDirectory(expandPath('~/'))
            dialog.setFileMode(QtWidgets.QFileDialog.AnyFile)
            dialog.setNameFilters(sorted(self.ontologyExporterNameFilters() + self.projectExporterNameFilters({File.Graphol})))
            dialog.setViewMode(QtWidgets.QFileDialog.Detail)
            dialog.selectFile(self.project.name)
            dialog.selectNameFilter(File.Owl.value)
            if dialog.exec_():
                filetype = File.valueOf(dialog.selectedNameFilter())
                try:
                    worker = self.createOntologyExporter(filetype, self.project, self)
                except ValueError:
                    worker = self.createProjectExporter(filetype, self.project, self)
                worker.run(expandPath(first(dialog.selectedFiles()))) 
Example #12
Source File: gui.py    From dottorrent-gui with GNU General Public License v3.0 6 votes vote down vote up
def import_profile(self):
        fn = QtWidgets.QFileDialog.getOpenFileName(
            self.MainWindow, 'Open profile', self.last_input_dir,
            filter=('JSON configuration file (*.json)'))[0]
        if fn:
            with open(fn) as f:
                data = json.load(f)
            exclude = data.get('exclude', [])
            trackers = data.get('trackers', [])
            web_seeds = data.get('web_seeds', [])
            private = data.get('private', False)
            compute_md5 = data.get('compute_md5', False)
            source = data.get('source', '')
            try:
                self.excludeEdit.setPlainText(os.linesep.join(exclude))
                self.trackerEdit.setPlainText(os.linesep.join(trackers))
                self.webSeedEdit.setPlainText(os.linesep.join(web_seeds))
                self.privateTorrentCheckBox.setChecked(private)
                self.md5CheckBox.setChecked(compute_md5)
                self.sourceEdit.setText(source)
            except Exception as e:
                self._showError(str(e))
                return
            self._statusBarMsg("Profile {} loaded".format(
                os.path.split(fn)[1])) 
Example #13
Source File: gui.py    From dottorrent-gui with GNU General Public License v3.0 6 votes vote down vote up
def export_profile(self):

        fn = QtWidgets.QFileDialog.getSaveFileName(
            self.MainWindow, 'Save profile', self.last_output_dir,
            filter=('JSON configuration file (*.json)'))[0]
        if fn:
            exclude = self.excludeEdit.toPlainText().strip().splitlines()
            trackers = self.trackerEdit.toPlainText().strip().split()
            web_seeds = self.webSeedEdit.toPlainText().strip().split()
            private = self.privateTorrentCheckBox.isChecked()
            compute_md5 = self.md5CheckBox.isChecked()
            source = self.sourceEdit.text()
            data = {
                'exclude': exclude,
                'trackers': trackers,
                'web_seeds': web_seeds,
                'private': private,
                'compute_md5': compute_md5,
                'source': source
            }
            with open(fn, 'w') as f:
                json.dump(data, f, indent=4, sort_keys=True)
            self._statusBarMsg("Profile saved to " + fn) 
Example #14
Source File: gui.py    From dottorrent-gui with GNU General Public License v3.0 6 votes vote down vote up
def createTorrent(self):
        if os.path.isfile(self.inputEdit.text()):
            save_fn = os.path.splitext(
                os.path.split(self.inputEdit.text())[1])[0] + '.torrent'
        else:
            save_fn = self.inputEdit.text().split(os.sep)[-1] + '.torrent'
        if self.last_output_dir and os.path.exists(self.last_output_dir):
            save_fn = os.path.join(self.last_output_dir, save_fn)
        fn = QtWidgets.QFileDialog.getSaveFileName(
            self.MainWindow, 'Save torrent', save_fn,
            filter=('Torrent file (*.torrent)'))[0]
        if fn:
            self.last_output_dir = os.path.split(fn)[0]
            self.creation_thread = CreateTorrentQThread(
                self.torrent,
                fn)
            self.creation_thread.started.connect(
                self.creation_started)
            self.creation_thread.progress_update.connect(
                self._progress_update)
            self.creation_thread.finished.connect(
                self.creation_finished)
            self.creation_thread.onError.connect(
                self._showError)
            self.creation_thread.start() 
Example #15
Source File: generate_brain_mask_tab.py    From MDT with GNU Lesser General Public License v3.0 6 votes vote down vote up
def _select_image(self):
        initial_dir = self._shared_state.base_dir
        if self.selectedImageText.text() != '':
            initial_dir = self.selectedImageText.text()

        open_file, used_filter = QFileDialog().getOpenFileName(
            caption='Select the 4d diffusion weighted image', directory=initial_dir,
            filter=';;'.join(image_files_filters))

        if os.path.isfile(open_file):
            self.selectedImageText.setText(open_file)
            self._shared_state.base_dir = os.path.dirname(open_file)

            if self.selectedOutputText.text() == '':
                split_path = split_image_path(open_file)
                self.selectedOutputText.setText(os.path.join(split_path[0], split_path[1] + '_mask' + split_path[2])) 
Example #16
Source File: workspace.py    From eddy with GNU General Public License v3.0 6 votes vote down vote up
def choosePath(self):
        """
        Bring up a modal window that allows the user to choose a valid workspace path.
        """
        path = self.workspaceField.value()
        if not isPathValid(path):
            path = expandPath('~')

        dialog = QtWidgets.QFileDialog(self)
        dialog.setAcceptMode(QtWidgets.QFileDialog.AcceptOpen)
        dialog.setDirectory(path)
        dialog.setFileMode(QtWidgets.QFileDialog.Directory)
        dialog.setOption(QtWidgets.QFileDialog.ShowDirsOnly, True)
        dialog.setViewMode(QtWidgets.QFileDialog.Detail)

        if dialog.exec_() == QtWidgets.QFileDialog.Accepted:
            self.workspaceField.setValue(first(dialog.selectedFiles())) 
Example #17
Source File: main_gui.py    From simnibs with GNU General Public License v3.0 6 votes vote down vote up
def coilDialog(self):
        #get folder with ccd files
        try:
            ccd_folder = os.path.join(SIMNIBSDIR, 'ccd-files')
        except:
            ccd_folder = './'


        dialog = QtWidgets.QFileDialog(self)
        dialog.setWindowTitle('Open Coil Definition File')
        dialog.setNameFilter('Coil Definition files (*.ccd *.nii *.gz)')
        dialog.setDirectory(ccd_folder)
        dialog.setFileMode(QtWidgets.QFileDialog.ExistingFile)
        if dialog.exec_() == QtWidgets.QDialog.Accepted:
            fn = str(dialog.selectedFiles()[0])
        else:
            return None

        self.tmslist.fnamecoil = fn
        self.coil_line_edit.setText(fn) 
Example #18
Source File: main_gui.py    From simnibs with GNU General Public License v3.0 6 votes vote down vote up
def openSimulation(self):
        dialog = QtWidgets.QFileDialog(self)
        dialog.setWindowTitle('Open GMSH File')
        dialog.setNameFilter('GMSH files (*.msh)')
        dialog.setDirectory(QtCore.QDir.currentPath())
        dialog.setFileMode(QtWidgets.QFileDialog.ExistingFile)
        if dialog.exec_() == QtWidgets.QDialog.Accepted:
            file_full_path = str(dialog.selectedFiles()[0])

        else:
            return None

        self.thread = openGmshThread(file_full_path)
        self.thread.start()



    #Generates a sim_struct.session() structure, for saving and running 
Example #19
Source File: CalibrationSettings.py    From nanovna-saver with GNU General Public License v3.0 6 votes vote down vote up
def loadCalibration(self):
        filename, _ = QtWidgets.QFileDialog.getOpenFileName(
            filter="Calibration Files (*.cal);;All files (*.*)")
        if filename:
            self.app.calibration.load(filename)
        if not self.app.calibration.isValid1Port():
            return
        for i, name in enumerate(
                ("short", "open", "load", "through", "isolation")):
            self.cal_label[name].setText(
                _format_cal_label(self.app.calibration.data_size(name), "Loaded"))
            if i == 2 and not self.app.calibration.isValid2Port():
                break
        self.calculate()
        self.notes_textedit.clear()
        for note in self.app.calibration.notes:
            self.notes_textedit.appendPlainText(note)
        self.app.settings.setValue("CalibrationFile", filename) 
Example #20
Source File: screens.py    From tinydecred with ISC License 5 votes vote down vote up
def loadClicked(self):
        """
        The user has selected the "load from file" option. Prompt for a file
        location and load the wallet.
        """
        fd = QtWidgets.QFileDialog(self, "select wallet file")
        fd.setViewMode(QtWidgets.QFileDialog.Detail)
        qdir = QtCore.QDir
        fd.setFilter(qdir.Dirs | qdir.Files | qdir.NoDotAndDotDot | qdir.Hidden)
        noFileMsg = "no file selected"
        if fd.exec_():
            fileNames = fd.selectedFiles()
            if len(fileNames) != 1:
                msg = "more than one file selected for importing"
                logError(msg)
                return
        else:
            log.info(noFileMsg)
            return
        walletPath = fileNames[0]
        log.debug(f"loading wallet from {walletPath}")
        if walletPath == "":
            logError(noFileMsg)
            return
        elif not os.path.isfile(walletPath):
            msg = f"no file found at {walletPath}"
            logError(msg)
            return
        elif not database.isSqlite3DB(walletPath):
            logError(f"{walletPath} is not a sqlite3 database")
            return

        destination = app.walletFilename()
        shutil.copy(walletPath, destination)
        app.initialize() 
Example #21
Source File: mainwindow.py    From CodeAtlasSublime with Eclipse Public License 1.0 5 votes vote down vote up
def onOpen(self):
		dialog = QtWidgets.QFileDialog()
		curDir = QtCore.QDir()
		curPath = curDir.currentPath()
		dbPath = dialog.getOpenFileName(self, 'Open Database', curDir.currentPath())
		if dbPath:
			dbmgr = DBManager.DBManager.instance()
			dbmgr.openDB(dbPath[0])

			from UIManager import UIManager
			symScene = UIManager.instance().getSymbolScene() 
Example #22
Source File: preferences.py    From BORIS with GNU General Public License v3.0 5 votes vote down vote up
def browseFFmpegCacheDir(self):
        """
        allow user select a cache dir for ffmpeg images
        """
        FFmpegCacheDir = QFileDialog().getExistingDirectory(self,
                                                            "Select a directory",
                                                            os.path.expanduser("~"),
                                                            options=QFileDialog().ShowDirsOnly)
        if FFmpegCacheDir:
            self.leFFmpegCacheDir.setText(FFmpegCacheDir) 
Example #23
Source File: plugin_jwt.py    From deen with Apache License 2.0 5 votes vote down vote up
def process_gui(self, parent, content):
        """Creating JWT tokens requires inputs for the
        secret and signature algorithm values."""
        self.parent = parent
        self.jwtgui = JwtGui(self.parent)
        self.file_open_dialog = QtWidgets.QFileDialog(self.jwtgui)
        self.jwtgui.ui.read_secret_file_button.clicked.connect(self._load_secret_dialog)
        if self.jwtgui.exec_() == 0:
            # If the plugin GUI is cancelled, just
            # return without doing anything.
            return
        algo = self.jwtgui.ui.algo_combo.currentText()
        if self.secret:
            secret = self.secret
        else:
            secret = self.jwtgui.ui.secret_input_field.toPlainText()
            if self.jwtgui.ui.secret_base64_checkbox.isChecked():
                try:
                    secret = base64.b64decode(secret)
                except Exception:
                    pass
        if algo in constants.ALGORITHMS.HMAC:
            return self.process(content, secret=secret, algo=algo)
        elif algo in constants.ALGORITHMS.RSA or \
                algo in constants.ALGORITHMS.EC:
            return self.process(content, key=secret, algo=algo)
        elif algo == 'none':
            return self.process(content, key=secret, algo='none') 
Example #24
Source File: Widgets.py    From PyRAT with Mozilla Public License 2.0 5 votes vote down vote up
def filesel(self):
        if self.type == 'openfile':
            self.value = str(QtWidgets.QFileDialog(self).getOpenFileName()[0])
        elif self.type == 'opendir':
            self.value = str(QtWidgets.QFileDialog(self).getExistingDirectory())
        elif self.type == 'savefile':
            self.value = str(QtWidgets.QFileDialog(self).getSaveFileName()[0])

        self.text.setText(self.value) 
Example #25
Source File: uefi_analyser.py    From UEFI_RETool with MIT License 5 votes vote down vote up
def _select_log(self):
        file_dialog = QtWidgets.QFileDialog()
        file_dialog.setFileMode(QtWidgets.QFileDialog.ExistingFiles)
        filename = None
        try:
            filename, _ = file_dialog.getOpenFileName(
                file_dialog, 'Select the {} log file'.format(NAME),
                self._last_directory, 'Results files (*.json)')
        except Exception as e:
            print('[{} error] {}'.format(NAME, str(e)))
        if filename:
            self._last_directory = os.path.dirname(filename)
        return filename 
Example #26
Source File: xai_viewer.py    From lung_nodule_detector with MIT License 5 votes vote down vote up
def __init__(self):
        super(Main_Window,self).__init__()

        ## set path and gpu number
        self.init_openpath = '/root/ssd_data/demo/'
        self.label_dirpath = '/root/ssd_data/luna_segment_attribute/'
        self.detect_resume = './detector.ckpt'
        self.gpu = '1'

        self.setupUi(self)
        self.actionOpen.triggered.connect(self.open)
        self.next_button.clicked.connect(self.next_slide)
        self.prev_button.clicked.connect(self.prev_slide)
        self.detect_button.clicked.connect(self.detect)
        self.horizontalScrollBar.valueChanged.connect(self.scroll_slide)
        self.listView.clicked.connect(self.click_nodule_list)

        self.resolution = np.array([1,1,1])
        self.slice_index = 0
        self.slice_num = 0
        self.slice_width = 0
        self.slice_height = 0

        self.detect_net, self.split_comber, self.get_pbb \
            = self.init_net()
        self.stride = 4
        self.n_per_run = 1
        self.detect_progressBar.setValue(0)
        self.fileopen_progressBar.setValue(0)

        self.file_dialog = QtWidgets.QFileDialog(directory=self.init_openpath)
        self.file_dialog.setNameFilters(["mhd files (*.mhd)", "Images (*.png *.jpg)", "All Files (*.*)"])
        self.file_dialog.selectNameFilter("mhd files (*.mhd)") 
Example #27
Source File: predefined_networks.py    From CNNArt with Apache License 2.0 5 votes vote down vote up
def editCell(self,r,c):
        if c==0:
            nameDialog = NameDialog(self.table.item(r,c))
            name = nameDialog.popUp()
            nameItem = QTableWidgetItem(name)
            self.table.setItem(r,0,nameItem)
            if r < len(self.networkHist):
                self.networkHist[r] = name
            else:
                self.networkHist.append(name)
        elif c==1:
            dialog = QtWidgets.QFileDialog()
            options = dialog.Options()
            options |= QtWidgets.QFileDialog.Directory
            options |= QtWidgets.QFileDialog.ExistingFile
            options |= QtWidgets.QFileDialog.DontUseNativeDialog
            dialog.setOptions(options)
            file_path = QtWidgets.QFileDialog.getOpenFileName(self, 'Choose the file', '.', 'python files(*.py)')[0]
            list = file_path.split('/')
            ind = list.index('networks')
            model_path = ''
            for item in list[ind:-1]:
                model_path = model_path + item + '/'
            model_path += list[-1]
            pathItem = QTableWidgetItem(model_path)
            self.table.setItem(r,1,pathItem) 
Example #28
Source File: session.py    From eddy with GNU General Public License v3.0 5 votes vote down vote up
def doImport(self):
        """
        Import an ontology into the currently active Project.
        """
        dialog = QtWidgets.QFileDialog(self)
        dialog.setAcceptMode(QtWidgets.QFileDialog.AcceptOpen)
        dialog.setDirectory(expandPath('~'))
        dialog.setFileMode(QtWidgets.QFileDialog.ExistingFiles)
        dialog.setViewMode(QtWidgets.QFileDialog.Detail)
        dialog.setNameFilters(self.ontologyLoaderNameFilters())
        if dialog.exec_():
            filetype = File.valueOf(dialog.selectedNameFilter())
            selected = [x for x in dialog.selectedFiles() if File.forPath(x) is filetype and fexists(x)]
            if selected:
                try:
                    with BusyProgressDialog(parent=self) as progress:
                        for path in selected:
                            progress.setWindowTitle('Importing {0}...'.format(os.path.basename(path)))
                            worker = self.createOntologyLoader(filetype, path, self.project, self)
                            worker.run()
                except Exception as e:
                    msgbox = QtWidgets.QMessageBox(self)
                    msgbox.setDetailedText(format_exception(e))
                    msgbox.setIconPixmap(QtGui.QIcon(':/icons/48/ic_error_outline_black').pixmap(48))
                    msgbox.setStandardButtons(QtWidgets.QMessageBox.Close)
                    msgbox.setText('Eddy could not import all the selected files!')
                    msgbox.setWindowIcon(QtGui.QIcon(':/icons/128/ic_eddy'))
                    msgbox.setWindowTitle('Import failed!')
                    msgbox.exec_() 
Example #29
Source File: welcome.py    From eddy with GNU General Public License v3.0 5 votes vote down vote up
def doOpen(self):
        """
        Bring up a modal window used to open a project.
        """
        dialog = QtWidgets.QFileDialog(self)
        dialog.setAcceptMode(QtWidgets.QFileDialog.AcceptOpen)
        dialog.setDirectory(expandPath(self.workspace))
        dialog.setFileMode(QtWidgets.QFileDialog.Directory)
        dialog.setOption(QtWidgets.QFileDialog.ShowDirsOnly, True)
        dialog.setViewMode(QtWidgets.QFileDialog.Detail)
        if dialog.exec_() == QtWidgets.QFileDialog.Accepted:
            self.sgnOpenProject.emit(first(dialog.selectedFiles())) 
Example #30
Source File: NanoVNASaver.py    From nanovna-saver with GNU General Public License v3.0 5 votes vote down vote up
def loadSweepFile(self):
        filename, _ = QtWidgets.QFileDialog.getOpenFileName(
            filter="Touchstone Files (*.s1p *.s2p);;All files (*.*)")
        if filename != "":
            self.data = []
            self.data21 = []
            t = Touchstone(filename)
            t.load()
            self.saveData(t.s11data, t.s21data, filename)
            self.dataUpdated()