Ejemplo n.º 1
0
    def on_featurePermissionRequested(self, securityOrigin, feature):
        if feature != QWebEnginePage.Geolocation:
            return

        mgsbox = QMessageBox(self)
        mgsbox.setAttribute(Qt.WA_DeleteOnClose)
        mgsbox.setText(
            self.tr("{} wants to know your location".format(securityOrigin.host()))
        )
        mgsbox.setInformativeText(
            self.tr("Do you want to send your current location to this website?")
        )
        mgsbox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
        mgsbox.setDefaultButton(QMessageBox.Yes)

        page = self.m_view.page()

        if mgsbox.exec_() == QMessageBox.Yes:
            page.setFeaturePermission(
                securityOrigin, feature, QWebEnginePage.PermissionGrantedByUser
            )
        else:
            page.setFeaturePermission(
                securityOrigin, feature, QWebEnginePage.PermissionDeniedByUser
            )
Ejemplo n.º 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"
Ejemplo n.º 3
0
def get_permission(message=None, cancel=True, title='Permission', parent=None):
    """
    Shows a permission message box
    :param message: str, message to show to the user
    :param cancel: bool, Whether the user can cancel the operation or not
    :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 message:
        message_box.setText(message)
    if cancel:
        message_box.setStandardButtons(QMessageBox.Yes | QMessageBox.No
                                       | QMessageBox.Cancel)
    else:
        message_box.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
    message_box.setWindowFlags(flags)
    result = message_box.exec_()

    if result == QMessageBox.Yes:
        return True
    elif result == QMessageBox.No:
        return False
    elif result == QMessageBox.Cancel:
        return None

    return None
Ejemplo n.º 4
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
Ejemplo n.º 5
0
 def _thread_fun(self, queue, device, show_q):
     self.queue = queue
     self.show_q = show_q
     if self.use_buffer:
         self.input_buffer = {}
     try:
         self.setup_connections()
         self.start(device)
         if DEBUG:
             print(f"{self.name} starting...")
         try:
             while True:
                 try:
                     FPS.update(self.name)
                     if self.use_buffer:
                         self.consume_queue_data()
                     self.run()
                 except StopNodeException:
                     break
         finally:
             self.end(device)
     except Exception as e:
         traceback.print_exc()
         instance = self.getWrapper().canvasRef().pyFlowInstance
         threading.Thread(target=stop_pipeline, args=(instance, )).start()
         msg = QMessageBox()
         msg.setIcon(QMessageBox.Critical)
         msg.setText("Error occured during node execution!")
         msg.setInformativeText(str(e))
         msg.setDetailedText(traceback.format_exc())
         msg.setWindowTitle("Node execution error!")
         msg.setStandardButtons(QMessageBox.Ok)
         msg.exec()
Ejemplo n.º 6
0
def generic_warning(message):
    from Qt.QtWidgets import QMessageBox
    msg = QMessageBox()
    msg.setIcon(QMessageBox.Warning)
    msg.setText(message)
    msg.setStandardButtons(QMessageBox.Ok)
    msg.exec_()
Ejemplo n.º 7
0
 def __init__(self, _msg):
     self.msg_box = QMessageBox()
     self.msg_box.setWindowFlags(self.msg_box.windowFlags()
                                 | QtCore.Qt.WindowStaysOnTopHint)
     self.msg_box.setWindowTitle("Warning")
     self.msg_box.setIcon(QMessageBox.Warning)
     self.msg_box.setStandardButtons(QMessageBox.Ok)
     self.msg_box.setText(_msg)
     self.msg_box.exec_()
Ejemplo n.º 8
0
    def handleAbout(self):
        """
        Displays the About dialog
        """

        about_box = QMessageBox()
        version_text = f"PyXPad version {version}\n\n"
        about_box.setText(version_text + __doc__.strip())
        about_box.exec_()
Ejemplo n.º 9
0
 def __init__(self):
     self.msg_box = QMessageBox()
     self.msg_box.setWindowFlags(self.msg_box.windowFlags()
                                 | QtCore.Qt.WindowStaysOnTopHint)
     self.msg_box.setWindowTitle("Error")
     self.msg_box.setIcon(QMessageBox.Critical)
     self.msg_box.setStandardButtons(QMessageBox.Ok)
     self.msg_box.setText("Select a file !")
     self.msg_box.exec_()
Ejemplo n.º 10
0
    def help_about(self):
        """About Hypnotoad"""

        about_text = __doc__.strip()
        about_text += f"\nVersion : {__version__}"

        about_box = QMessageBox(self)
        about_box.setText(about_text)
        about_box.exec_()
Ejemplo n.º 11
0
 def __init__(self):
     self.msg_box = QMessageBox()
     self.msg_box.setWindowFlags(self.msg_box.windowFlags()
                                 | QtCore.Qt.WindowStaysOnTopHint)
     self.msg_box.setWindowTitle("Error")
     self.msg_box.setIcon(QMessageBox.Warning)
     self.msg_box.setStandardButtons(QMessageBox.Ok)
     self.msg_box.setText("File selected not valid")
     self.msg_box.exec_()
Ejemplo n.º 12
0
 def create_new_directory(self):
     name, ok = QInputDialog.getText(self, 'New directory name', 'Name:',
                                     QLineEdit.Normal, 'New Directory')
     if ok and name:
         path = os.path.join(self.directory, name)
         if os.path.exists(path):
             msg_box = QMessageBox(self)
             msg_box.setWindowTitle('Error')
             msg_box.setText('Directory already exists')
             msg_box.exec_()
         else:
             try:
                 os.makedirs(path)
                 self.update_view()
             except os.error as e:
                 msg_box = QMessageBox(self)
                 msg_box.setWindowTitle('Error')
                 msg_box.setText('Cannot create directory')
                 msg_box.exec_()
Ejemplo n.º 13
0
 def accept(self, *args, **kwargs):
     selected_file, selected_dir, selected_file_name = self.get_result()
     if not os.path.isdir(selected_file):
         if os.path.exists(selected_file):
             super(BaseOpenFileDialog, self).accept()
         else:
             message_box = QMessageBox()
             message_box.setWindowTitle('Confirme file selection')
             message_box.setText(
                 'File "{0}" does not exists!'.format(selected_file))
             message_box.exec_()
Ejemplo n.º 14
0
    def show_info_dialog(self, msg, title='Info'):
        """
        Shows a info dialog
        :param msg: str, message to show with the dialog
        :param title: str, title of the dialog
        """

        dialog = QMessageBox()
        dialog.setIcon(QMessageBox.Information)
        dialog.setWindowTitle(title)
        dialog.setText(msg)
        dialog.exec_()
Ejemplo n.º 15
0
    def libadd_ring(self):
        """add ring to library or open it in a new model"""
        selection = self.session.seqcrow_ordered_selection_manager.selection

        if not selection.single_structure:
            raise RuntimeError("selected atoms must be on the same model")

        rescol = ResidueCollection(selection[0].structure)
        walk_atoms = rescol.find(
            [AtomSpec(atom.atomspec) for atom in selection])

        if len(walk_atoms) < 1:
            raise RuntimeError("no walk direction could be determined")

        ring_name = self.ring_name.text()
        ring = Ring(rescol, name=ring_name, end=walk_atoms)
        ring.comment = "E:%s" % ",".join(
            [str(rescol.atoms.index(atom) + 1) for atom in walk_atoms])

        if len(ring_name) == 0:
            chimerax_ring = ResidueCollection(ring).get_chimera(self.session)
            chimerax_ring.name = "ring preview"
            self.session.models.add([chimerax_ring])
            bild_obj = show_walk_highlight(ring, chimerax_ring,
                                           [0.9, 0.4, 0.3, 0.9], self.session)
            self.session.models.add(bild_obj, parent=chimerax_ring)

        else:
            check_aaronlib_dir()
            filename = os.path.join(AARONLIB, "Rings", ring_name + ".xyz")
            if os.path.exists(filename):
                exists_warning = QMessageBox()
                exists_warning.setIcon(QMessageBox.Warning)
                exists_warning.setText(
                    "%s already exists.\nWould you like to overwrite?" %
                    filename)
                exists_warning.setStandardButtons(QMessageBox.Yes
                                                  | QMessageBox.No)

                rv = exists_warning.exec_()
                if rv == QMessageBox.Yes:
                    ring.write(outfile=filename)
                    self.tool_window.status("%s added to ring library" %
                                            ring_name)

                else:
                    self.tool_window.status(
                        "%s has not been added to ring library" % ring_name)

            else:
                ring.write(outfile=filename)
                self.tool_window.status("%s added to ring library" % ring_name)
Ejemplo n.º 16
0
def warning_message(message, parent=None):
    """
    Shows a warning message
    :param message: str
    :param parent: QWidget
    """

    parent = None
    message_box = QMessageBox(parent)
    flags = message_box.windowFlags(
    ) ^ Qt.WindowContextHelpButtonHint | Qt.WindowStaysOnTopHint
    message_box.setWindowFlags(flags)
    message_box.warning(parent, 'Warning', message)
Ejemplo n.º 17
0
def critical_message(message, parent=None):
    """
    Shows a critical message
    :param message: str
    :param parent: QWidget
    """

    parent = None
    message_box = QMessageBox(parent)
    flags = message_box.windowFlags(
    ) ^ Qt.WindowContextHelpButtonHint | Qt.WindowStaysOnTopHint
    message_box.setWindowFlags(flags)
    message_box.critical(parent, 'Critical Error', message)
Ejemplo n.º 18
0
def about_message(message, parent=None):
    """
    Shows an about message
    :param message: str
    :param parent: QWidget
    """

    parent = None
    message_box = QMessageBox(parent)
    flags = message_box.windowFlags(
    ) ^ Qt.WindowContextHelpButtonHint | Qt.WindowStaysOnTopHint
    message_box.setWindowFlags(flags)
    message_box.about(parent, 'About', message)
Ejemplo n.º 19
0
 def save(self):
     if not config.HAVE_PYEVTK:
         msg = QMessageBox(QMessageBox.Critical, 'Error', 'VTK output disabled. Pleas install pyvtk.')
         msg.exec_()
         return
     filename = QFileDialog.getSaveFileName(self, 'Save as vtk file')[0]
     base_name = filename.split('.vtu')[0].split('.vtk')[0].split('.pvd')[0]
     if base_name:
         if len(self.U) == 1:
             write_vtk(self.grid, NumpyVectorSpace.make_array(self.U[0]), base_name, codim=self.codim)
         else:
             for i, u in enumerate(self.U):
                 write_vtk(self.grid, NumpyVectorSpace.make_array(u), f'{base_name}-{i}',
                           codim=self.codim)
Ejemplo n.º 20
0
    def show_warning_dialog(self, msg, detail=None):
        """
        Shows a warning dialog
        :param msg: str, message to show with the dialog
        :param detail: str, detail information to show (optional)
        """

        dialog = QMessageBox()
        dialog.setIcon(QMessageBox.Warning)
        dialog.setWindowTitle('Warning')
        dialog.setText(msg)
        if detail:
            dialog.setDetailedText(detail)
        dialog.exec_()
Ejemplo n.º 21
0
def choice_warning(message):
    '''
    Pop up a warning dialog box with the given message, and return True
    if the user wants to go ahead.
    '''
    from Qt.QtWidgets import QMessageBox
    msg = QMessageBox()
    msg.setIcon(QMessageBox.Warning)
    msg.setText(message)
    msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
    reply = msg.exec_()
    if reply == QMessageBox.Ok:
        return True
    return False
Ejemplo n.º 22
0
 def setPassword(self):
     newPassword = self.let_password.text()
     if not newPassword:
         msgBox = QMessageBox()
         msgBox.setText(u'请输入密码!')
         msgBox.exec_()
         return 0
     colUser = userdb[self.username]
     # 从数据库提取密码
     for x in colUser.find({"_id": "Password"}, {"Password": 1}):
         if "Password" in x:
             DBpassword = x["Password"]
     oldD = {"Password": DBpassword}
     newD = {"$set": {"Password": newPassword}}
     x = colUser.update_many(oldD, newD)
Ejemplo n.º 23
0
 def _fun(self, device):
     try:
         self.setup_connections()
         self.run(device)
     except Exception as e:
         traceback.print_exc()
         self._terminate()
         msg = QMessageBox()
         msg.setIcon(QMessageBox.Critical)
         msg.setText("Error occured during node execution!")
         msg.setInformativeText(str(e))
         msg.setDetailedText(traceback.format_exc())
         msg.setWindowTitle("Node execution error!")
         msg.setStandardButtons(QMessageBox.Ok)
         msg.exec()
Ejemplo n.º 24
0
    def show_confirm_dialog(self, msg, title='Title'):
        """
        Shows a yes/no confirmation dialog
        :param msg: str, message to show with the dialog
        :param title: str, title of the dialog
        :return: bool, Whether the user has pressed yes(True) or No(False)
        """

        dialog = QMessageBox()
        dialog.setIcon(QMessageBox.Question)
        result = dialog.question(self.parent_window, title, msg,
                                 QMessageBox.Yes, QMessageBox.No)
        if result == QMessageBox.Yes:
            return True
        return False
Ejemplo n.º 25
0
    def _ask_user_subset_override(self, instance):
        from Qt.QtWidgets import QMessageBox

        title = "Subset \"{}\" already exist".format(instance["subset"])
        text = ("Instance with subset name \"{}\" already exists."
                "\n\nDo you want to override existing?").format(
                    instance["subset"])

        dialog = QMessageBox()
        dialog.setWindowTitle(title)
        dialog.setText(text)
        dialog.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
        dialog.setDefaultButton(QMessageBox.Yes)
        dialog.exec_()
        if dialog.result() == QMessageBox.Yes:
            return True
        return False
Ejemplo n.º 26
0
 def accept(self, *args, **kwargs):
     selected_file, selected_dir, selected_filename = self.get_result()
     if not os.path.isdir(selected_file):
         if os.path.exists(selected_file):
             message_box = QMessageBox()
             message_box.setWindowTitle('Confirm File Selection')
             message_box.setText(
                 'File "%s" exists.\nDo you want to overwrite it?' %
                 selected_file)
             message_box.setStandardButtons(QMessageBox.Yes
                                            | QMessageBox.No)
             message_box.setDefaultButton(QMessageBox.No)
             rv = message_box.exec_()
             if rv == QMessageBox.Yes and not os.path.isdir(selected_file):
                 super(BaseSaveFileDialog, self).accept()
     else:
         super(BaseSaveFileDialog, self).accept()
Ejemplo n.º 27
0
def save():
    """
    Saves current scene in current Maya file
    :return: bool, Whether the scene was saved or not
    """

    file_check_state = maya.cmds.file(query=True, modified=True)
    if file_check_state:
        msg_box = QMessageBox()
        msg_box.setText('The Maya scene has been modified')
        msg_box.setInformativeText('Do you want to save your changes?')
        msg_box.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
        msg_box.setDefaultButton(QMessageBox.Yes)
        res = msg_box.exec_()
        if res == QMessageBox.Yes:
            maya.cmds.SaveScene()
            return True

    return False
Ejemplo n.º 28
0
def save(file_path=None):
    """
    Saves current scene in current Max file
    :return: bool, Whether the scene was saved or not
    """

    file_path = file_path or ''
    file_check_state = rt.getSaveRequired()
    if file_check_state:
        msg_box = QMessageBox()
        msg_box.setText('The 3ds Max scene has been modified')
        msg_box.setInformativeText('Do you want to save your changes?')
        msg_box.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
        msg_box.setDefaultButton(QMessageBox.Yes)
        res = msg_box.exec_()
        if res == QMessageBox.Yes:
            file_path = file_path or directory.save_file_dialog('Save File', filters='*.max')
            if not file_path:
                return
            rt.saveMaxFile(file_path)
            return True

    return False
Ejemplo n.º 29
0
def save(force=False):
    """
    Saves current scene in current Max file
    :return: bool, Whether the scene was saved or not
    """

    file_check_state = MaxPlus.FileManager.IsSaveRequired()
    if file_check_state:
        if file_check_state:
            if force:
                MaxPlus.FileManager.Save()
                return True
            else:
                msg_box = QMessageBox()
                msg_box.setText('The 3ds Max scene has been modified')
                msg_box.setInformativeText('Do you want to save your changes?')
                msg_box.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
                msg_box.setDefaultButton(QMessageBox.Yes)
                res = msg_box.exec_()
                if res == QMessageBox.Yes:
                    MaxPlus.FileManager.Save()
                    return True

    return False
Ejemplo n.º 30
0
def msgbox(message, detail=None):
    msgbox = QMessageBox()
    msgbox.setText(message)
    if detail:
        msgbox.setDetailedText(detail)
    return msgbox.exec_()