Exemple #1
0
    def addXPADtree(self):
        try:
            from pyxpad.xpadsource import XPadSource
        except ImportError:
            self.main.write("Sorry, no XPAD tree support")
            self.main.write(str(sys.exc_info()))
            return

        try:
            # Select the directory
            tr = self.main.tr
            dname = QFileDialog.getExistingDirectory(self.main, tr('Open XPAD directory'),
                                                     QDir.currentPath())
            if (dname == "") or (dname is None):
                return
            # Create data source
            s = XPadSource(dname)

            # Add data source and update
            self.addSource(s)
            self.updateDisplay()
        except:
            self.main.write("Error creating XPadSource")
            self.main.write(str(sys.exc_info()))
            raise
Exemple #2
0
 def pickPath(self):
     initialPath = self.uiFilenameTXT.text() or self.defaultLocation
     initialPath = str(initialPath)
     while not os.path.exists(initialPath):
         if os.path.dirname(initialPath) == initialPath:
             break
         else:
             initialPath = os.path.dirname(initialPath)
     if QApplication.keyboardModifiers() == Qt.ControlModifier:
         import blurdev
         blurdev.osystem.explore(initialPath)
     else:
         if self._pickFolder:
             filepath = QFileDialog.getExistingDirectory(
                 self, self._caption, initialPath)
         elif self._openFile:
             filepath, _ = QtCompat.QFileDialog.getOpenFileName(
                 self, self._caption, initialPath, self._filters)
         else:
             filepath, _ = QtCompat.QFileDialog.getSaveFileName(
                 self, self._caption, initialPath, self._filters)
         if filepath:
             self.uiFilenameTXT.setText(filepath)
             if (not self.signalsBlocked()):
                 self.filenamePicked.emit(filepath)
Exemple #3
0
    def addXPADtree(self):
        """Add an XPad tree as a data source, if UDA is available"""
        try:
            from pyxpad.xpadsource import XPadSource
        except ImportError:
            self.main.write("Sorry, no XPAD tree support")
            self.main.write(str(sys.exc_info()))
            return

        try:
            # Select the directory
            tr = self.main.tr
            dname = QFileDialog.getExistingDirectory(self.main,
                                                     tr("Open XPAD directory"),
                                                     QDir.currentPath())
            if (dname == "") or (dname is None):
                return
            # Create data source
            s = XPadSource.from_tree(dname)

            # Add data source and update
            self.addSource(s)
            self.updateDisplay()
        except:
            self.main.write("Error creating XPadSource")
            self.main.write(str(sys.exc_info()))
            raise
Exemple #4
0
    def _on_browse(self):
        """
        Opens file dialog
        """

        path = self.value()
        path = QFileDialog.getExistingDirectory(None, 'Browse Folder', path)
        if path:
            self.set_value(path)
Exemple #5
0
def select_folder_dialog(title, start_directory=None):
    """
    Shows select folder dialog
    :param title: str
    :param start_directory: str
    :return: str
    """

    return QFileDialog.getExistingDirectory(None, title, start_directory)
Exemple #6
0
def browse_folder(self):
    r_folder = QFileDialog.getExistingDirectory(self, 'Browse Folder',
                                                self.path)
    if not r_folder:
        return

    if self.multiple:
        self.foldersChanged.emit([r_folder])
    else:
        self.folderChanged.emit(r_folder)
    self.path = r_folder
Exemple #7
0
def _choose_phenix_directory(session):
    satisfied = False
    from Qt.QtWidgets import QFileDialog, QMessageBox
    parent = session.ui.main_window
    import subprocess, os
    while not satisfied:
        result = QFileDialog.getExistingDirectory(parent, 'Please provide the directory containing the Phenix executables.', options=QFileDialog.Options())
        if not result:
            break
        try:
            subprocess.call([os.path.join(result,'phenix.version')])
            satisfied = True
        except FileNotFoundError:
            choice = QMessageBox.warning(parent, 'This directory does not appear to contain Phenix executables. Would you like to try again?',
                QMessageBox.Ok|QMessageBox.Cancel)
        except:
            raise
    if not satisfied:
        from chimerax.core.errors import UserError
        raise UserError('Could not find Phenix installation. Operation cancelled')
    return result
    def show_move_dialog(self, parent=None):
        """
        Shows the move to browser dialog
        :param parent: QWidget
        """

        path = os.path.dirname(self.path())
        target = QFileDialog.getExistingDirectory(parent, 'Move To ...', path)
        if target:
            try:
                move_function = self.item.functionality().get('move')
                if not move_function:
                    self.show_error_dialog('Delete Error', 'Item "{}" does not supports move operation'.format(self))
                    return
                source = self.item.format_identifier()
                if os.path.isdir(source):
                    target = path_utils.join_path(target, os.path.basename(source))
                move_function(target)
            except Exception as exc:
                self.show_exception_dialog('Move Error', exc, traceback.format_exc())
                raise
Exemple #9
0
    def addBOUT(self):
        """
        Add a BOUT++ directory source
        """
        try:
            from pyxpad.boutsource import BoutDataSource

            # Select the directory
            tr = self.main.tr
            dname = QFileDialog.getExistingDirectory(self.main, tr('Open BOUT++ directory'),
                                                     QDir.currentPath())
            if (dname == "") or (dname is None):
                return
            # Create data source
            s = BoutDataSource(dname)

            # Add data source and update
            self.addSource(s)
            self.updateDisplay()
        except:
            self.main.write("Sorry, no BOUT++ support")
            raise
            return
Exemple #10
0
    def addBOUT(self):
        """
        Add a BOUT++ directory source, if boutdata is available
        """
        try:
            from pyxpad.boutsource import BoutDataSource

            # Select the directory
            tr = self.main.tr
            dname = QFileDialog.getExistingDirectory(
                self.main, tr("Open BOUT++ directory"), QDir.currentPath())
            if (dname == "") or (dname is None):
                return
            # Create data source
            s = BoutDataSource(dname)

            # Add data source and update
            self.addSource(s)
            self.updateDisplay()
        except:
            self.main.write("Sorry, no BOUT++ support")
            raise
            return
Exemple #11
0
 def pickFolder():
     '''Pick a folder from Dialog'''
     return str(QFileDialog.getExistingDirectory(None, "Select Directory"))