Beispiel #1
0
def get_save_permission(message,
                        file_path=None,
                        title='Permission',
                        parent=None):
    """
    Shows a save path message box
    :param message: str, message to show to the user
    :param file_path: str, path you want to save
    :param title: str, title of the window
    :param parent: QWidget
    :return: bool
    """

    message_box = QMessageBox()
    message_box.setWindowTitle(title)
    flags = message_box.windowFlags(
    ) ^ Qt.WindowContextHelpButtonHint | Qt.WindowStaysOnTopHint
    if file_path:
        path_message = 'Path: {}'.format(file_path)
        message_box.setInformativeText(path_message)
    message_box.setWindowFlags(flags)
    save = message_box.addButton('Save', QMessageBox.YesRole)
    no_save = message_box.addButton('Do not save', QMessageBox.NoRole)
    cancel = message_box.addButton('Cancel', QMessageBox.RejectRole)
    message_box.exec_()

    if message_box.clickedButton() == save:
        return True
    elif message_box.clickedButton() == no_save:
        return False
    elif message_box.clickedButton() == cancel:
        return None

    return None
Beispiel #2
0
def failed_template_warning(residue):
    '''
    Warning dialog handling the case where a template is not recognised by
    OpenMM when attempting to start a simulation.
    '''
    from Qt.QtWidgets import QMessageBox, QPushButton
    msg = QMessageBox()
    msg.setIcon(QMessageBox.Warning)
    msgtext = 'Residue {} {} of chain {} (shown) does not match any template'\
        + ' in the molecular dynamics database. It may be missing atoms (have'\
        + ' you added hydrogens?) or be an unusual residue that has not been'\
        + ' parameterised. Choose what you wish to do with it from the options'\
        + ' below.'
    msg.setText(msgtext.format(residue.name, residue.number, residue.chain_id))

    addh = QPushButton('Add hydrogens and retry')
    msg.addButton(addh, QMessageBox.AcceptRole)
    exclude = QPushButton('Exclude residue from simulations and retry')
    msg.addButton(exclude, QMessageBox.RejectRole)
    abort = QPushButton('Abort')
    msg.addButton(abort, QMessageBox.NoRole)
    msg.exec_()
    btn = msg.clickedButton()
    # print("Button: {}".format(btn))
    if btn == addh:
        return "addh"
    if btn == exclude:
        return "exclude"
    return "abort"