当前位置: 首页>>代码示例>>Python>>正文


Python QMessageBox.question方法代码示例

本文整理汇总了Python中PyQt5.QtWidgets.QMessageBox.question方法的典型用法代码示例。如果您正苦于以下问题:Python QMessageBox.question方法的具体用法?Python QMessageBox.question怎么用?Python QMessageBox.question使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtWidgets.QMessageBox的用法示例。


在下文中一共展示了QMessageBox.question方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: closeEvent

# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import question [as 别名]
def closeEvent(self, event):
        """Display a message before leaving

        Parameters
        ----------
        self : DMachineSetup
            A DMachineSetup object
        event :
            The closing event
        """

        if self.is_save_needed:
            quit_msg = self.tr(
                "Unsaved changes will be lost.\nDo you want to save the machine?"
            )
            reply = QMessageBox.question(
                self,
                self.tr("Please save before closing"),
                quit_msg,
                QMessageBox.Yes,
                QMessageBox.No,
            )

            if reply == QMessageBox.Yes:
                self.s_save() 
开发者ID:Eomys,项目名称:pyleecan,代码行数:27,代码来源:DMachineSetup.py

示例2: _onRemovedPrintersMessageActionTriggered

# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import question [as 别名]
def _onRemovedPrintersMessageActionTriggered(self, removed_printers_message: Message, action: str) -> None:
        if action == "keep_printer_configurations_action":
            removed_printers_message.hide()
        elif action == "remove_printers_action":
            machine_manager = CuraApplication.getInstance().getMachineManager()
            remove_printers_ids = {self._um_cloud_printers[i].getId() for i in self.reported_device_ids}
            all_ids = {m.getId() for m in CuraApplication.getInstance().getContainerRegistry().findContainerStacks(type = "machine")}

            question_title = self.I18N_CATALOG.i18nc("@title:window", "Remove printers?")
            question_content = self.I18N_CATALOG.i18nc("@label", "You are about to remove {} printer(s) from Cura. This action cannot be undone. \nAre you sure you want to continue?".format(len(remove_printers_ids)))
            if remove_printers_ids == all_ids:
                question_content = self.I18N_CATALOG.i18nc("@label", "You are about to remove all printers from Cura. This action cannot be undone. \nAre you sure you want to continue?")
            result = QMessageBox.question(None, question_title, question_content)
            if result == QMessageBox.No:
                return

            for machine_cloud_id in self.reported_device_ids:
                machine_manager.setActiveMachine(self._um_cloud_printers[machine_cloud_id].getId())
                machine_manager.removeMachine(self._um_cloud_printers[machine_cloud_id].getId())
            removed_printers_message.hide() 
开发者ID:Ultimaker,项目名称:Cura,代码行数:22,代码来源:CloudOutputDeviceManager.py

示例3: closeEvent

# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import question [as 别名]
def closeEvent(self, event):
        """关闭事件"""
        reply = QMessageBox.question(self, u'退出',
                                     u'确认退出?', QMessageBox.Yes |
                                     QMessageBox.No, QMessageBox.No)
        
        if reply == QMessageBox.Yes:
            for widget in list(self.widgetDict.values()):
                widget.close()
            
            self.mainEngine.exit()
            event.accept()
        else:
            event.ignore()
    
    # ---------------------------------------------------------------------- 
开发者ID:quantOS-org,项目名称:TradeSim,代码行数:18,代码来源:uiMainWindow.py

示例4: profile_delete_action

# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import question [as 别名]
def profile_delete_action(self):
        if self.profileSelector.count() > 1:
            to_delete = BackupProfileModel.get(id=self.profileSelector.currentData())

            # Remove pending background jobs
            to_delete_id = str(to_delete.id)
            msg = self.tr("Are you sure you want to delete profile '{}'?".format(to_delete.name))
            reply = QMessageBox.question(self, self.tr("Confirm deletion"),
                                         msg, QMessageBox.Yes | QMessageBox.No, QMessageBox.No)

            if reply == QMessageBox.Yes:
                if self.app.scheduler.get_job(to_delete_id):
                    self.app.scheduler.remove_job(to_delete_id)

                to_delete.delete_instance(recursive=True)
                self.profileSelector.removeItem(self.profileSelector.currentIndex())
                self.profile_select_action(0) 
开发者ID:borgbase,项目名称:vorta,代码行数:19,代码来源:main_window.py

示例5: closeEvent

# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import question [as 别名]
def closeEvent(self, event):
        # Save window state in SettingsModel
        SettingsModel.update({SettingsModel.str_value: str(self.frameGeometry().width())})\
            .where(SettingsModel.key == 'previous_window_width')\
            .execute()
        SettingsModel.update({SettingsModel.str_value: str(self.frameGeometry().height())})\
            .where(SettingsModel.key == 'previous_window_height')\
            .execute()

        if not is_system_tray_available():
            run_in_background = QMessageBox.question(self,
                                                     trans_late("MainWindow QMessagebox",
                                                                "Quit"),
                                                     trans_late("MainWindow QMessagebox",
                                                                "Should Vorta continue to run in the background?"),
                                                     QMessageBox.Yes | QMessageBox.No)
            if run_in_background == QMessageBox.No:
                self.app.quit()
        event.accept() 
开发者ID:borgbase,项目名称:vorta,代码行数:21,代码来源:main_window.py

示例6: checkScanAlreadyRunning

# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import question [as 别名]
def checkScanAlreadyRunning(self):
        errcode, errmsg, hasBluetooth, hasUbertooth, spectrumScanRunning, discoveryScanRunning =  getRemoteBluetoothRunningServices(self.remoteAgentIP, self.remoteAgentPort)      
        
        if errcode == 0:
            if discoveryScanRunning:
                self.btnScan.setStyleSheet("background-color: rgba(255,0,0,255); border: none;")
                self.btnScan.setText('&Stop scanning')
                self.comboScanType.setEnabled(False)
            else:
                self.btnScan.setStyleSheet("background-color: rgba(2,128,192,255); border: none;")
                self.btnScan.setText('&Scan')
                self.comboScanType.setEnabled(True)
        else:
                QMessageBox.question(self, 'Error',"Error getting remote agent discovery status: " + errmsg, QMessageBox.Ok)

                self.btnScan.setStyleSheet("background-color: rgba(2,128,192,255); border: none;")
                self.btnScan.setText('&Scan')
                self.comboScanType.setEnabled(True) 
开发者ID:ghostop14,项目名称:sparrow-wifi,代码行数:20,代码来源:sparrowdialogs.py

示例7: getRemoteFile

# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import question [as 别名]
def getRemoteFile(self, agentIP, agentPort, filename):
        url = "http://" + agentIP + ":" + str(agentPort) + "/system/getrecording/" + filename

        dirname, runfilename = os.path.split(os.path.abspath(__file__))
        recordingsDir = dirname + '/recordings'
        fullPath = recordingsDir + '/' + filename
        
        if os.path.isfile(fullPath):
            reply = QMessageBox.question(self, 'Question',"Local file by that name already exists.  Overwrite?", QMessageBox.Yes | QMessageBox.No, QMessageBox.No)

            if reply == QMessageBox.No:
                return
        
        try:
            # urllib.urlretrieve(url, fullPath)
            urlretrieve(url, fullPath)
            return 0, ""
        except:
            return 1, "Error downloading and saving file." 
开发者ID:ghostop14,项目名称:sparrow-wifi,代码行数:21,代码来源:sparrowdialogs.py

示例8: promptToSave

# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import question [as 别名]
def promptToSave(self):
        if cm.ConfigManager.SETTINGS[cm.PROMPT_TO_SAVE]:
            # TODO: i18n
            result = QMessageBox.question(
                self.window(),
                "Save changes?",
                "There are unsaved changes. Would you like to save them?",
                QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel
            )

            if result == QMessageBox.Yes:
                return self.on_save()
            elif result == QMessageBox.Cancel:
                return True
            else:
                return False
        else:
            # don't prompt, just save
            return self.on_save()

    # ---- Signal handlers 
开发者ID:autokey,项目名称:autokey,代码行数:23,代码来源:centralwidget.py

示例9: closeEvent

# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import question [as 别名]
def closeEvent(self, event):
        reply = QMessageBox.question(self, 'Exit',
            "Are you sure to quit?", QMessageBox.Yes |
            QMessageBox.No, QMessageBox.No)

        if reply == QMessageBox.Yes:
            print dn
            os.chdir(dn)
            print dn
            os.chdir('../..')
            print dn
            print '''
###################################################
#              Author Storm Shadow                #
#                                                 #
#              Follow me on twitter               #
#                  @zadow28                       #
###################################################
#              Ida pro  python Editor             #
###################################################
'''
            event.accept()
        else:
            event.ignore() 
开发者ID:techbliss,项目名称:Python_editor,代码行数:26,代码来源:pyeditor.py

示例10: save_protocol

# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import question [as 别名]
def save_protocol(self):
        for msg in self.proto_analyzer.messages:
            if not msg.decoder.is_nrz:
                reply = QMessageBox.question(self, "Saving of protocol",
                                             "You want to save this protocol with an encoding different from NRZ.\n"
                                             "This may cause loss of information if you load it again.\n\n"
                                             "Save anyway?", QMessageBox.Yes | QMessageBox.No)
                if reply != QMessageBox.Yes:
                    return
                else:
                    break

        text = "protocol"
        filename = FileOperator.get_save_file_name("{0}.proto.xml".format(text), caption="Save protocol")

        if not filename:
            return

        if filename.endswith(".bin"):
            self.proto_analyzer.to_binary(filename, use_decoded=True)
        else:
            self.proto_analyzer.to_xml_file(filename=filename, decoders=self.decodings,
                                            participants=self.project_manager.participants, write_bits=True) 
开发者ID:jopohl,项目名称:urh,代码行数:25,代码来源:CompareFrameController.py

示例11: save_before_close

# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import question [as 别名]
def save_before_close(self):
        if not self.already_saved and self.device.current_index > 0:
            reply = QMessageBox.question(self, self.tr("Save data?"),
                                         self.tr("Do you want to save the data you have captured so far?"),
                                         QMessageBox.Yes | QMessageBox.No | QMessageBox.Abort)
            if reply == QMessageBox.Yes:
                self.on_save_clicked()
            elif reply == QMessageBox.Abort:
                return False

        try:
            sample_rate = self.device.sample_rate
        except:
            sample_rate = 1e6

        self.files_recorded.emit(self.recorded_files, sample_rate)
        return True 
开发者ID:jopohl,项目名称:urh,代码行数:19,代码来源:ReceiveDialog.py

示例12: closeEvent

# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import question [as 别名]
def closeEvent(self, event):
        self.pywebview_window.closing.set()
        if self.confirm_close:
            reply = QMessageBox.question(self, self.title, localization['global.quitConfirmation'],
                                         QMessageBox.Yes, QMessageBox.No)

            if reply == QMessageBox.No:
                event.ignore()
                return

        event.accept()
        BrowserView.instances[self.uid].close()
        del BrowserView.instances[self.uid]

        if self.pywebview_window in windows:
            windows.remove(self.pywebview_window)

        self.pywebview_window.closed.set()

        if len(BrowserView.instances) == 0:
            self.hide()
            _app.exit() 
开发者ID:r0x0r,项目名称:pywebview,代码行数:24,代码来源:qt.py

示例13: holdingContext

# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import question [as 别名]
def holdingContext(self, pos):
        '''
        Creates the context menu for the Holding

        Args:
            pos (QModelIndex): index of the selected row

        Returns:
            None
        '''
        if self.hModel.rowCount() > 0:
            menu = QMenu()
            delX = menu.addAction('Sell Tick')

            action = menu.exec_(self.holding.mapToGlobal(pos))
            rowTick = self.hTicks[self.holding.rowAt(pos.y())]

            if action == delX:
                if rowTick.tradeable:
                    reply = QMessageBox.question(
                        None, 'Sell?', 'Sell {} shares of {} for at {}'.format(
                            rowTick.PQ, rowTick.T,
                            rowTick.C), QMessageBox.Yes, QMessageBox.No)
                    if reply == QMessageBox.Yes:
                        rowTick.toSell(
                            purPrice=self.purPrice.value(),
                            spy=self.spy,
                            forced=True)
                        self._executeOrder(rowTick, orderType='Sell') 
开发者ID:aseylys,项目名称:KStock,代码行数:31,代码来源:KStock.py

示例14: dump

# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import question [as 别名]
def dump(self, clicked=False):
        '''
        Sells the remaining stocks if there are any current purchases

        Args:
            clicked (bool): whether the 'Dump All' button was pressed

        Returns:
            None
        '''
        if self.hModel.rowCount() > 0:
            if clicked:
                msg = 'Are you sure you want to dump all currently held stocks?'
                dumpDia = QMessageBox.question(self, 'Are You Sure', msg,
                                               QMessageBox.Yes, QMessageBox.No)
                if dumpDia == QMessageBox.No: return

            logging.info('---- Selling all positions ----')
            ticksToSell = [tick for tick in self.hTicks if tick.tradeable]

            while len(ticksToSell) > 0:
                ticker = ticksToSell.pop(0)
                _executeOrder(ticker, orderType='Sell')
                time.sleep(0.25)

        if not clicked:
            self.tradeActs() 
开发者ID:aseylys,项目名称:KStock,代码行数:29,代码来源:KStock.py

示例15: try_close_model

# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import question [as 别名]
def try_close_model(self):
        if self._model_mgr.modified:
            reply = QMessageBox.question(
                self.modeler,
                "OPC UA Modeler",
                "Model is modified, do you really want to close model?",
                QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel
            )
            if reply != QMessageBox.Yes:
                return False
        self._model_mgr.close_model(force=True)
        return True 
开发者ID:FreeOpcUa,项目名称:opcua-modeler,代码行数:14,代码来源:uamodeler.py


注:本文中的PyQt5.QtWidgets.QMessageBox.question方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。