Example #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
Example #2
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
            )
Example #3
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()
Example #4
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()
Example #5
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
Example #6
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
Example #7
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