Python PyQt5.QtWidgets.QMessageBox.Warning() Examples

The following are 22 code examples of PyQt5.QtWidgets.QMessageBox.Warning(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyQt5.QtWidgets.QMessageBox , or try the search function .
Example #1
Source File: configinit.py    From qutebrowser with GNU General Public License v3.0 6 votes vote down vote up
def late_init(save_manager: savemanager.SaveManager) -> None:
    """Initialize the rest of the config after the QApplication is created."""
    global _init_errors
    if _init_errors is not None:
        errbox = msgbox.msgbox(parent=None,
                               title="Error while reading config",
                               text=_init_errors.to_html(),
                               icon=QMessageBox.Warning,
                               plain_text=False)
        errbox.exec_()

        if _init_errors.fatal:
            sys.exit(usertypes.Exit.err_init)

    _init_errors = None

    configtypes.FontBase.set_defaults(config.val.fonts.default_family,
                                      config.val.fonts.default_size)
    config.instance.changed.connect(_update_font_defaults)

    config.instance.init_save_manager(save_manager)
    configfiles.state.init_save_manager(save_manager) 
Example #2
Source File: hw_setup_dlg.py    From dash-masternode-tool with MIT License 6 votes vote down vote up
def on_btnEnDisPin_clicked(self):
        try:
            if self.hw_session and self.hw_session.hw_client:
                if self.pin_protection is True:
                    # disable
                    if self.queryDlg('Do you really want to disable PIN protection of your %s?' % self.main_ui.getHwName(),
                                     buttons=QMessageBox.Yes | QMessageBox.Cancel, default_button=QMessageBox.Cancel,
                                     icon=QMessageBox.Warning) == QMessageBox.Yes:
                        hw_intf.change_pin(self.main_ui.hw_session, remove=True)
                        self.read_hw_features()
                        self.updateControlsState()
                elif self.pin_protection is False:
                    # enable PIN
                    hw_intf.change_pin(self.main_ui.hw_session, remove=False)
                    self.read_hw_features()
                    self.updateControlsState()

        except Exception as e:
            self.errorMsg(str(e)) 
Example #3
Source File: hw_setup_dlg.py    From dash-masternode-tool with MIT License 6 votes vote down vote up
def on_btnEnDisPass_clicked(self):
        try:
            if self.hw_session and self.hw_session.hw_client:
                if self.passphrase_protection is True:
                    # disable passphrase
                    if self.queryDlg('Do you really want to disable passphrase protection of your %s?' % self.main_ui.getHwName(),
                                     buttons=QMessageBox.Yes | QMessageBox.Cancel, default_button=QMessageBox.Cancel,
                                     icon=QMessageBox.Warning) == QMessageBox.Yes:
                        hw_intf.enable_passphrase(self.hw_session, passphrase_enabled=False)
                        self.read_hw_features()
                        self.updateControlsState()
                elif self.passphrase_protection is False:
                    # enable passphrase
                    if self.queryDlg('Do you really want to enable passphrase protection of your %s?' % self.main_ui.getHwName(),
                                     buttons=QMessageBox.Yes | QMessageBox.Cancel, default_button=QMessageBox.Cancel,
                                     icon=QMessageBox.Warning) == QMessageBox.Yes:
                        hw_intf.enable_passphrase(self.hw_session, passphrase_enabled=True)
                        self.read_hw_features()
                        self.updateControlsState()

        except Exception as e:
            self.errorMsg(str(e)) 
Example #4
Source File: main.py    From Blender-Version-Manager with GNU General Public License v3.0 6 votes vote down vote up
def main():
    QApplication.setApplicationName("Blender Version Manager")
    QApplication.setApplicationVersion("1.6.1 Beta")

    app = QApplication(sys.argv)

    proc_count = len([proc for proc in psutil.process_iter()
                      if proc.name() == "Blender Version Manager.exe"])

    if proc_count > 2:
        msg = QMessageBox(QMessageBox.Warning, "Blender Version Manager",
                          "Another instance is already running!",
                          QMessageBox.Ok)
        msg.setWindowIcon(QIcon(":/icons/app.svg"))
        msg.exec_()
    else:
        window = BVMQMainWindow(app)

        if not window.is_run_minimized:
            window.show()

        app.exec_() 
Example #5
Source File: window.py    From visma with GNU General Public License v3.0 5 votes vote down vote up
def warning(self, warningstr):
        warning = QMessageBox()
        warning.setWindowTitle('Warning')
        warning.setIcon(QMessageBox.Warning)
        warning.setText(warningstr)
        warning.setStandardButtons(QMessageBox.Ok)
        return warning.exec_() 
Example #6
Source File: core.py    From gridsync with GNU General Public License v3.0 5 votes vote down vote up
def show_message():
        message_settings = settings.get("message")
        if not message_settings:
            return
        if get_preference("message", "suppress") == "true":
            return
        logging.debug("Showing custom message to user...")
        msgbox = QMessageBox()
        icon_type = message_settings.get("type")
        if icon_type:
            icon_type = icon_type.lower()
            if icon_type == "information":
                msgbox.setIcon(QMessageBox.Information)
            elif icon_type == "warning":
                msgbox.setIcon(QMessageBox.Warning)
            elif icon_type == "critical":
                msgbox.setIcon(QMessageBox.Critical)
        if sys.platform == "darwin":
            msgbox.setText(message_settings.get("title"))
            msgbox.setInformativeText(message_settings.get("text"))
        else:
            msgbox.setWindowTitle(message_settings.get("title"))
            msgbox.setText(message_settings.get("text"))
        checkbox = QCheckBox("Do not show this message again")
        checkbox.stateChanged.connect(
            lambda state: set_preference(
                "message", "suppress", ("true" if state else "false")
            )
        )
        msgbox.setCheckBox(checkbox)
        msgbox.exec_()
        logging.debug("Custom message closed; proceeding with start...") 
Example #7
Source File: misc.py    From PIVX-SPMT with MIT License 5 votes vote down vote up
def checkTxInputs(parentWindow, num_of_inputs):
    if num_of_inputs == 0:
        myPopUp_sb(parentWindow, "warn", 'Transaction NOT sent', "No UTXO to send")
        return None

    if num_of_inputs > MAX_INPUTS_NO_WARNING:
        warning = "Warning: Trying to spend %d inputs.\nA few minutes could be required " \
                  "for the transaction to be prepared and signed.\n\nThe hardware device must remain unlocked " \
                  "during the whole time (it's advised to disable the auto-lock feature)\n\n" \
                  "Do you wish to proceed?" % num_of_inputs
        title = "SPMT - spending more than %d inputs" % MAX_INPUTS_NO_WARNING
        return myPopUp(parentWindow, "warn", title, warning)

    return QMessageBox.Yes 
Example #8
Source File: PLSDR.py    From PLSDR with GNU General Public License v3.0 5 votes vote down vote up
def message_dialog(self,title,message):
    mb = QMessageBox (QMessageBox.Warning,title,message,QMessageBox.Ok)
    mb.exec_() 
Example #9
Source File: dataRecord.py    From face_recognition_py with GNU General Public License v3.0 5 votes vote down vote up
def detectFace(self, frame):
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        faces = self.faceCascade.detectMultiScale(gray, 1.3, 5, minSize=(90, 90))

        stu_id = self.userInfo.get('stu_id')

        for (x, y, w, h) in faces:
            if self.isFaceRecordEnabled:
                try:
                    if not os.path.exists('{}/stu_{}'.format(self.datasets, stu_id)):
                        os.makedirs('{}/stu_{}'.format(self.datasets, stu_id))
                    if len(faces) > 1:
                        raise RecordDisturbance

                    cv2.imwrite('{}/stu_{}/img.{}.jpg'.format(self.datasets, stu_id, self.faceRecordCount + 1),
                                gray[y - 20:y + h + 20, x - 20:x + w + 20])
                except RecordDisturbance:
                    self.isFaceRecordEnabled = False
                    logging.error('检测到多张人脸或环境干扰')
                    self.logQueue.put('Warning:检测到多张人脸或环境干扰,请解决问题后继续')
                    self.enableFaceRecordButton.setIcon(QIcon('./icons/warning.png'))
                    continue
                except Exception as e:
                    logging.error('写入人脸图像文件到计算机过程中发生异常')
                    self.enableFaceRecordButton.setIcon(QIcon('./icons/error.png'))
                    self.logQueue.put('Error:无法保存人脸图像,采集当前捕获帧失败')
                else:
                    self.enableFaceRecordButton.setIcon(QIcon('./icons/success.png'))
                    self.faceRecordCount = self.faceRecordCount + 1
                    self.isFaceRecordEnabled = False
                    self.faceRecordCountLcdNum.display(self.faceRecordCount)
            cv2.rectangle(frame, (x - 5, y - 10), (x + w + 5, y + h + 10), (0, 0, 255), 2)

        return frame

    # 显示图像 
Example #10
Source File: util.py    From guppy-proxy with MIT License 5 votes vote down vote up
def display_error_box(msg, title="Error"):
    msgbox = QMessageBox()
    msgbox.setIcon(QMessageBox.Warning)
    msgbox.setText(msg)
    msgbox.setWindowTitle(title)
    msgbox.setStandardButtons(QMessageBox.Ok)
    return msgbox.exec_() 
Example #11
Source File: qmessagebox.py    From linux-show-player with GNU General Public License v3.0 5 votes vote down vote up
def dwarning(title, text, detailed_text, parent=None):
        """MessageBox with "Warning" icon"""
        QDetailedMessageBox.dgeneric(title,
                                     text,
                                     detailed_text,
                                     QMessageBox.Warning,
                                     parent) 
Example #12
Source File: fit_model_tab.py    From MDT with GNU Lesser General Public License v3.0 5 votes vote down vote up
def __init__(self, problems, *args):
        super().__init__(*args)
        self.setIcon(QMessageBox.Warning)
        self.setWindowTitle("Insufficient protocol")
        self.setText("The provided protocol is insufficient for this model.")
        self.setInformativeText("The reported problems are: \n{}".format('\n'.join(' - ' + str(p) for p in problems)))
        self._in_resize = False 
Example #13
Source File: main_dlg.py    From dash-masternode-tool with MIT License 5 votes vote down vote up
def on_btnDeleteMn_clicked(self):
        if self.cur_masternode:
            msg = QMessageBox()
            msg.setIcon(QMessageBox.Warning)
            msg.setText('Do you really want to delete current masternode configuration?')
            msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
            msg.setDefaultButton(QMessageBox.No)
            retval = msg.exec_()
            if retval == QMessageBox.No:
                return
            self.app_config.masternodes.remove(self.cur_masternode)
            self.cboMasternodes.removeItem(self.cboMasternodes.currentIndex())
            self.app_config.modified = True
            self.update_edit_controls_state() 
Example #14
Source File: main_dlg.py    From dash-masternode-tool with MIT License 5 votes vote down vote up
def on_action_clear_proposals_cache_triggered(self, checked):
        if self.queryDlg('Do you really want to clear the proposals cache?',
                         buttons=QMessageBox.Yes | QMessageBox.Cancel,
                         default_button=QMessageBox.Cancel, icon=QMessageBox.Warning) == QMessageBox.Yes:
            db_cursor = self.app_config.db_intf.get_cursor()
            try:
                db_cursor.execute('drop table proposals')
                db_cursor.execute('drop table voting_results')
                self.app_config.db_intf.create_structures()
            finally:
                self.app_config.db_intf.release_cursor()
            self.infoMsg('Proposals cache cleared.') 
Example #15
Source File: main_dlg.py    From dash-masternode-tool with MIT License 5 votes vote down vote up
def on_action_clear_wallet_cache_triggered(self, checked):
        if self.queryDlg('Do you really want to clear the wallet cache?',
                         buttons=QMessageBox.Yes | QMessageBox.Cancel,
                         default_button=QMessageBox.Cancel, icon=QMessageBox.Warning) == QMessageBox.Yes:
            db_cursor = self.app_config.db_intf.get_cursor()
            try:
                db_cursor.execute('drop table address')
                db_cursor.execute('drop table hd_tree')
                db_cursor.execute('drop table tx_input')
                db_cursor.execute('drop table tx_output')
                db_cursor.execute('drop table tx')
                self.app_config.db_intf.create_structures()
            finally:
                self.app_config.db_intf.release_cursor()
            self.infoMsg('Wallet cache cleared.') 
Example #16
Source File: main_dlg.py    From dash-masternode-tool with MIT License 5 votes vote down vote up
def load_configuration_from_file(self, file_name: str, ask_save_changes = True,
                                     update_current_file_name = True) -> None:
        """
        Load configuration from a file.
        :param file_name: A name of the configuration file to be loaded into the application.
        """
        if self.app_config.is_modified() and ask_save_changes:
            ret = self.queryDlg('Current configuration has been modified. Save?',
                                buttons=QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel,
                                default_button=QMessageBox.Yes, icon=QMessageBox.Warning)
            if ret == QMessageBox.Yes:
                self.save_configuration()
            elif ret == QMessageBox.Cancel:
                self.update_config_files_mru_menu_items()
                return

        try:
            self.disconnect_hardware_wallet()
            dash_network_sav = self.app_config.dash_network
            self.app_config.read_from_file(hw_session=self.hw_session, file_name=file_name,
                                           update_current_file_name=update_current_file_name)
            self.editing_enabled = False
            self.configuration_to_ui()
            self.dashd_intf.reload_configuration()
            self.app_config.modified = False
            file_name = self.app_config.app_config_file_name
            if file_name:
                self.add_item_to_config_files_mru_list(file_name)
                self.update_config_files_mru_menu_items()
                if dash_network_sav != self.app_config.dash_network:
                    self.disconnect_hardware_wallet()
                    self.app_config.reset_network_dependent_dyn_params()
            self.display_window_title()
        except CancelException:
            self.update_config_files_mru_menu_items() 
Example #17
Source File: masternode_details.py    From dash-masternode-tool with MIT License 5 votes vote down vote up
def generate_priv_key(self, pk_type:str, edit_control: QLineEdit, compressed: bool):
        if edit_control.text():
            if WndUtils.queryDlg(
                    f'This will overwrite the current {pk_type} private key value. Do you really want to proceed?',
                     buttons=QMessageBox.Yes | QMessageBox.Cancel,
                     default_button=QMessageBox.Yes, icon=QMessageBox.Warning) != QMessageBox.Yes:
                return None

        if pk_type == 'operator':
            pk = dash_utils.generate_bls_privkey()
        else:
            pk = dash_utils.generate_wif_privkey(self.app_config.dash_network, compressed=compressed)
        edit_control.setText(pk)
        return pk 
Example #18
Source File: GroundSystem.py    From cFS-GroundSystem with Apache License 2.0 5 votes vote down vote up
def DisplayErrorMessage(self, message):
        print(message)
        self.alert.setText(message)
        self.alert.setIcon(QMessageBox.Warning)
        self.alert.exec_()

    # Start the telemetry system for the selected spacecraft 
Example #19
Source File: setting.py    From persepolis with GNU General Public License v3.0 5 votes vote down vote up
def callBack(self, keys):
        # do nothing if keys is empty
        if not(keys):
            return

        # check that if shortcut used before.
        if keys in self.shortcuts_list:
            self.msgBox = QMessageBox()
            self.msgBox.setText(QCoreApplication.translate("setting_src_ui_tr", "<b><center>This shortcut has been used before!\
                    Use another one!</center></b>"))
            self.msgBox.setIcon(QMessageBox.Warning)
            reply = self.msgBox.exec_()

        # set new shortcut
        else:
            selected_row = self.shortcut_table.selectionModel().selectedRows()[0].row()

            item = QTableWidgetItem(keys)

            # align center
            item.setTextAlignment(0x0004 | 0x0080)

            # insert item in shortcut_table
            self.shortcut_table.setItem(selected_row, 1, item)

            # set keys in shortcuts_list
            self.shortcuts_list[selected_row] = keys

    # active color_comboBox only when user is select "Fusion" style. 
Example #20
Source File: initialize_hw_dlg.py    From dash-masternode-tool with MIT License 4 votes vote down vote up
def apply_step_select_action(self) -> bool:
        """Moves forward from the 'select action' step."""
        success = True
        self.read_action_type_from_ui()
        if self.action_type in (ACTION_RECOVER_FROM_WORDS_CONV, ACTION_RECOVER_FROM_WORDS_SAFE,
                                ACTION_INITIALIZE_NEW_SAFE):

            self.set_next_step(STEP_INPUT_NUMBER_OF_WORDS)

        elif self.action_type == ACTION_RECOVER_FROM_ENTROPY:

            self.set_next_step(STEP_INPUT_ENTROPY)

        elif self.action_type == ACTION_WIPE_DEVICE:
            if self.hw_type in (HWType.trezor, HWType.keepkey):
                if self.queryDlg('Do you really want to wipe your %s device?' % self.hw_type,
                                 buttons=QMessageBox.Yes | QMessageBox.Cancel,
                                 default_button=QMessageBox.Cancel, icon=QMessageBox.Warning) == QMessageBox.Yes:
                    try:
                        self.load_hw_devices()
                        cnt = len(self.hw_device_instances)
                        if cnt == 0:
                            self.errorMsg('Couldn\'t find any %s devices connected to your computer.' %
                                          HWType.get_desc(self.hw_type))
                            success = False
                        elif cnt == 1:
                            # there is only one instance of this device type
                            self.hw_device_id_selected = self.hw_device_instances[0][0]
                            self.hw_device_index_selected = 0
                            success = self.apply_action_on_hardware_wallet()
                            if success:
                                self.set_next_step(STEP_FINISHED)
                        else:
                            # there is more than one instance of this device type; go to the device instance selection tab
                            self.set_next_step(STEP_SELECT_DEVICE_INSTANCE)
                            success = True
                    except CancelException:
                        self.warnMsg('Operation cancelled.')
                        success = False
                else:
                    success = False

        elif self.action_type == ACTION_UPLOAD_FIRMWARE:

            if self.hw_type in (HWType.trezor, HWType.keepkey):

                self.set_next_step(STEP_INPUT_FIRMWARE_SOURCE)

            else:
                self.errorMsg(f'{HWType.get_desc(self.hw_type)} is not supported.')
                success = False

        else:
            raise Exception('Not implemented')
        return success 
Example #21
Source File: core.py    From face_recognition_py with GNU General Public License v3.0 4 votes vote down vote up
def startWebcam(self):
        if not self.cap.isOpened():
            if self.isExternalCameraUsed:
                camID = 1
            else:
                camID = 0
            self.cap.open(camID)
            self.cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
            self.cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
            ret, frame = self.cap.read()
            if not ret:
                logging.error('无法调用电脑摄像头{}'.format(camID))
                self.logQueue.put('Error:初始化摄像头失败')
                self.cap.release()
                self.startWebcamButton.setIcon(QIcon('./icons/error.png'))
            else:
                self.faceProcessingThread.start()  # 启动OpenCV图像处理线程
                self.timer.start(5)  # 启动定时器
                self.panalarmThread.start()  # 启动报警系统线程
                self.startWebcamButton.setIcon(QIcon('./icons/success.png'))
                self.startWebcamButton.setText('关闭摄像头')

        else:
            text = '如果关闭摄像头,须重启程序才能再次打开。'
            informativeText = '<b>是否继续?</b>'
            ret = CoreUI.callDialog(QMessageBox.Warning, text, informativeText, QMessageBox.Yes | QMessageBox.No,
                                    QMessageBox.No)

            if ret == QMessageBox.Yes:
                self.faceProcessingThread.stop()
                if self.cap.isOpened():
                    if self.timer.isActive():
                        self.timer.stop()
                    self.cap.release()

                self.realTimeCaptureLabel.clear()
                self.realTimeCaptureLabel.setText('<font color=red>摄像头未开启</font>')
                self.startWebcamButton.setText('摄像头已关闭')
                self.startWebcamButton.setEnabled(False)
                self.startWebcamButton.setIcon(QIcon())

    # 定时器,实时更新画面 
Example #22
Source File: dataManage.py    From face_recognition_py with GNU General Public License v3.0 4 votes vote down vote up
def deleteUser(self):
        text = '从数据库中删除该用户,同时删除相应人脸数据,<font color=red>该操作不可逆!</font>'
        informativeText = '<b>是否继续?</b>'
        ret = DataManageUI.callDialog(QMessageBox.Warning, text, informativeText, QMessageBox.Yes | QMessageBox.No,
                                      QMessageBox.No)

        if ret == QMessageBox.Yes:
            stu_id = self.stuIDLineEdit.text()
            conn = sqlite3.connect(self.database)
            cursor = conn.cursor()

            try:
                cursor.execute('DELETE FROM users WHERE stu_id=?', (stu_id,))
            except Exception as e:
                cursor.close()
                logging.error('无法从数据库中删除{}'.format(stu_id))
                self.deleteUserButton.setIcon(QIcon('./icons/error.png'))
                self.logQueue.put('Error:读写数据库异常,删除失败')
            else:
                cursor.close()
                conn.commit()
                if os.path.exists('{}/stu_{}'.format(self.datasets, stu_id)):
                    try:
                        shutil.rmtree('{}/stu_{}'.format(self.datasets, stu_id))
                    except Exception as e:
                        logging.error('系统无法删除删除{}/stu_{}'.format(self.datasets, stu_id))
                        self.logQueue.put('Error:删除人脸数据失败,请手动删除{}/stu_{}目录'.format(self.datasets, stu_id))

                text = '你已成功删除学号为 <font color=blue>{}</font> 的用户记录。'.format(stu_id)
                informativeText = '<b>请在右侧菜单重新训练人脸数据。</b>'
                DataManageUI.callDialog(QMessageBox.Information, text, informativeText, QMessageBox.Ok)

                self.stuIDLineEdit.clear()
                self.cnNameLineEdit.clear()
                self.faceIDLineEdit.clear()
                self.initDb()
                self.deleteUserButton.setIcon(QIcon('./icons/success.png'))
                self.deleteUserButton.setEnabled(False)
                self.queryUserButton.setIcon(QIcon())
            finally:
                conn.close()

    # 检测人脸