Ejemplo n.º 1
0
def askyesno_qt(title, message, parent=None, buttons_text=None):
    """
    Wrapper to a Yes/no dialog in PyQt. If 'buttons_text' is 'None', the default
    "Yes" and "No" buttons will be used. If 'buttons_text' is a list with two
    strings, the first string will be the text of the "Yes" button and the second
    one will be the text of the "No" button.
    """

    # Use yes and no buttons.
    if buttons_text is None:
        answer = QtWidgets.QMessageBox.question(parent, title, message,
                                                QtWidgets.QMessageBox.Yes,
                                                QtWidgets.QMessageBox.No)
        return answer == QtWidgets.QMessageBox.Yes

    # Set custom text on the buttons.
    else:
        dialog = QtWidgets.QMessageBox(parent)
        dialog.setWindowTitle(title)
        dialog.setText(message)
        yesbutton = dialog.addButton(buttons_text[0],
                                     QtWidgets.QMessageBox.YesRole)
        nobutton = dialog.addButton(buttons_text[1],
                                    QtWidgets.QMessageBox.NoRole)
        answer = dialog.exec_()
        return dialog.clickedButton() is yesbutton
Ejemplo n.º 2
0
    def openDocumentation(self):
        if not self.readTheDocsURL:
            if not self.settings['local_docs']:
                msg = QtWidgets.QMessageBox()
                msg.setIcon(QtWidgets.QMessageBox.Information)
                msg.setWindowTitle("Location of docs not configured")
                msg.setStandardButtons(QtWidgets.QMessageBox.Ok
                                       | QtWidgets.QMessageBox.Cancel)
                msg.setText(
                    'Press <OK> and specify the path of the local docs.')
                returnValue = msg.exec_()
                if returnValue == QtWidgets.QMessageBox.Ok:
                    self.set_localdocsDir()

        if not self.settings['browser']:
            msg = QtWidgets.QMessageBox()
            msg.setIcon(QtWidgets.QMessageBox.Information)
            msg.setWindowTitle("Web browser not configured")
            msg.setStandardButtons(QtWidgets.QMessageBox.Ok
                                   | QtWidgets.QMessageBox.Cancel)
            msg.setText(
                'For the documentation to be displayed, the path to a web browser needs to be configured. Press <OK> and search for the browser executable (Firefox, Chrome or Edge).'
            )
            returnValue = msg.exec_()
            if returnValue == QtWidgets.QMessageBox.Ok:
                self.set_browser()

        if self.settings['browser']:
            try:
                browser = webbrowser.get('{} %s'.format(
                    self.settings['browser']))
                browser.open('file://{}/index.html'.format(
                    self.settings['local_docs']))
            except webbrowser.Error:
                self.settings['browser'] = None
                print('Browser not found!')
                with open(
                        '{}/.fretraj_settings.conf'.format(package_directory),
                        'w') as f:
                    json.dump(self.settings, f, indent=2)
            except FileNotFoundError:
                self.settings['local_docs'] = None
                print('Local docs not found!')
                with open(
                        '{}/.fretraj_settings.conf'.format(package_directory),
                        'w') as f:
                    json.dump(self.settings, f, indent=2)
Ejemplo n.º 3
0
 def error_msg(text, informative_text=None):
     msg = QtWidgets.QMessageBox()
     msg.setIcon(QtWidgets.QMessageBox.Critical)
     msg.setWindowTitle("PyViewDock")
     msg.setText(text)
     if informative_text:
         msg.setInformativeText(informative_text)
     msg.exec_()
Ejemplo n.º 4
0
 def openErrorWin(self, title, message):
     """
     Open Error Window
     """
     msg = QtWidgets.QMessageBox()
     msg.setIcon(QtWidgets.QMessageBox.Critical)
     msg.setWindowTitle(title)
     msg.setText(message)
     msg.exec_()
Ejemplo n.º 5
0
 def openExample(self, name, fileformat):
     """
     Load an example file and calculate an ACV
     """
     fileNamePath_pdb = '{}/{}{}'.format(self.exampleDataPath, name,
                                         fileformat)
     fileNamePath_param = '{}/{}_labels{}'.format(self.exampleDataPath,
                                                  name, '.json')
     pdb_load = self.loadPDB(fileNamePath_pdb)
     if pdb_load:
         param_load = self.loadParameterFile(fileNamePath_param)
         if param_load:
             msg = QtWidgets.QMessageBox()
             msg.setIcon(QtWidgets.QMessageBox.Information)
             msg.setWindowTitle("Calculate ACV?")
             msg.setStandardButtons(QtWidgets.QMessageBox.Yes
                                    | QtWidgets.QMessageBox.No)
             msg.setText('Would you like to calculate an ACV?')
             returnValue = msg.exec_()
             if returnValue == QtWidgets.QMessageBox.Yes:
                 n_pos = 0
                 for pos in self.labels['Position'].keys():
                     if pos != self.labelName_default:
                         index = self.comboBox_labelName.findText(
                             pos, QtCore.Qt.MatchExactly)
                         self.comboBox_labelName.setCurrentIndex(index)
                         self.computeACV()
                         n_pos += 1
                 if n_pos > 1:
                     self.comboBox_donorName.setStyleSheet(
                         'QComboBox {background-color: rgb(229,134,145);}')
                     self.comboBox_acceptorName.setStyleSheet(
                         'QComboBox {background-color: rgb(229,134,145);}')
                     msg = QtWidgets.QMessageBox()
                     msg.setIcon(QtWidgets.QMessageBox.Information)
                     msg.setWindowTitle("Calculate FRET?")
                     msg.setText(
                         'To calculate FRET select the donor and acceptor position from the highlighted dropdown menu and press on <Calculate FRET>'
                     )
                     returnValue = msg.exec_()
                     self.comboBox_donorName.setStyleSheet('')
                     self.comboBox_acceptorName.setStyleSheet('')
Ejemplo n.º 6
0
 def openAbout(self):
     """
     Open About Window
     """
     msg = QtWidgets.QMessageBox()
     pixmap = utils.QtGui.QPixmap(self.uiIcon)
     msg.setIconPixmap(pixmap.scaledToWidth(64))
     msg.setWindowTitle("About FRETraj")
     msg.setText('{} {}\n\n{}\n\n(C) {}'.format(about['__title__'],
                                                str(about['__version__']),
                                                about['__description__'],
                                                about['__copyright__']))
     msg.exec_()
Ejemplo n.º 7
0
def update_pyvol(form):
    """ GUI wrapper for updating PyVOL using pip

    """

    update_pypi_pyvol()

    msg = QtWidgets.QMessageBox()
    msg.setIcon(QtWidgets.QMessageBox.Information)
    msg.setWindowTitle("PyVOL Updated")
    msg.setInformativeText("The PyVOL backend has been updated; however, PyMOL will not load the new code until it is restarted.")
    msg.setStandardButtons(QtWidgets.QMessageBox.Ok)
    msg.setMinimumSize(QtCore.QSize(600, 200)) # Doesn't seem to work
    msg.exec_()

    refresh_installation_status(form)
Ejemplo n.º 8
0
def uninstall_pyvol(form):
    """ Attempts to uninstall PyVOL using pip

    """

    subprocess.check_output([sys.executable, "-m", "pip", "uninstall", "-y", "bio-pyvol"])

    msg = QtWidgets.QMessageBox()
    msg.setIcon(QtWidgets.QMessageBox.Information)
    msg.setWindowTitle("PyVOL Backend Uninstalled")
    msg.setInformativeText("The PyVOL backend has been uninstalled; however, the plugin must also be uninstalled using PyMOL's plugin manager.")
    msg.setStandardButtons(QtWidgets.QMessageBox.Ok)
    msg.setMinimumSize(QtCore.QSize(600, 200)) # Doesn't seem to work
    msg.exec_()

    refresh_installation_status(form)
Ejemplo n.º 9
0
def update_pyvol():
    """ Attempts to update PyVOL using conda

    """
    from conda.cli import python_api
    python_api.run_command(python_api.Commands.UPDATE, "bio-pyvol")

    msg = QtWidgets.QMessageBox()
    msg.setIcon(QtWidgets.QMessageBox.Information)
    msg.setWindowTitle("PyVOL Updated")
    msg.setInformativeText(
        "The PyVOL backend has been updated; however, PyMOL will not load the new code until it is restarted."
    )
    msg.setStandardButtons(QtWidgets.QMessageBox.Ok)
    msg.setMinimumSize(QtCore.QSize(600, 200))  # Doesn't seem to work
    msg.exec_()

    refresh_installation_status(form)
Ejemplo n.º 10
0
    def update_pyvol(form):
        """ Attempts to update PyVOL using pip

        """
        import subprocess
        import sys

        form.status_label.setText("Updating PyVOL")
        subprocess.check_output(
            [sys.executable, "-m", "pip", "install", "--upgrade", "bio-pyvol"])

        msg = QtWidgets.QMessageBox()
        msg.setIcon(QtWidgets.QMessageBox.Information)
        msg.setWindowTitle("PyVOL Updated")
        msg.setInformativeText(
            "The PyVOL backend has been updated; however, PyMOL will not load the new code until it is restarted."
        )
        msg.setStandardButtons(QtWidgets.QMessageBox.Ok)
        msg.setMinimumSize(QtCore.QSize(600, 200))  # Doesn't seem to work
        msg.exec_()

        refresh_installation_status(form)