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


Python QMessageBox.question方法代码示例

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


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

示例1: add_columns

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import question [as 别名]
    def add_columns(self):
        if self.ui.columns.currentIndex() <= 0:
            return
        ag = self.ui.columns.currentText()
        if self.evt.focus == "where":  # in where section
            if ag in self.col_where:  # column already called in where section
                response = QMessageBox.question(self, "Column already used in WHERE clause", "Do you want to add column %s again?" % ag, QMessageBox.Yes | QMessageBox.No)
                if response == QMessageBox.No:
                    self.ui.columns.setCurrentIndex(0)
                    return
            self.ui.where.insertPlainText(ag)
            self.col_where.append(ag)
        elif self.evt.focus == "col":
            if ag in self.col_col:  # column already called in col section
                response = QMessageBox.question(self, "Column already used in COLUMNS section", "Do you want to add column %s again?" % ag, QMessageBox.Yes | QMessageBox.No)
                if response == QMessageBox.No:
                    self.ui.columns.setCurrentIndex(0)
                    return
            if len(self.ui.col.toPlainText().strip()) > 0:
                self.ui.col.insertPlainText(",\n" + ag)
            else:
                self.ui.col.insertPlainText(ag)
            self.col_col.append(ag)
        elif self.evt.focus == "group":
            if len(self.ui.group.toPlainText().strip()) > 0:
                self.ui.group.insertPlainText(", " + ag)
            else:
                self.ui.group.insertPlainText(ag)
        elif self.evt.focus == "order":
            if len(self.ui.order.toPlainText().strip()) > 0:
                self.ui.order.insertPlainText(", " + ag)
            else:
                self.ui.order.insertPlainText(ag)

        self.ui.columns.setCurrentIndex(0)
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:37,代码来源:dlg_query_builder.py

示例2: runAction

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import question [as 别名]
    def runAction(self, action):
        action = unicode(action)

        if action.startswith("rows/"):
            if action == "rows/count":
                self.refreshRowCount()
                return True

        elif action.startswith("triggers/"):
            parts = action.split('/')
            trigger_action = parts[1]

            msg = QApplication.translate("DBManagerPlugin", "Do you want to %s all triggers?") % trigger_action
            QApplication.restoreOverrideCursor()
            try:
                if QMessageBox.question(None, QApplication.translate("DBManagerPlugin", "Table triggers"), msg,
                                        QMessageBox.Yes | QMessageBox.No) == QMessageBox.No:
                    return False
            finally:
                QApplication.setOverrideCursor(Qt.WaitCursor)

            if trigger_action == "enable" or trigger_action == "disable":
                enable = trigger_action == "enable"
                self.emitAboutToChange()
                self.database().connector.enableAllTableTriggers(enable, (self.schemaName(), self.name))
                self.refreshTriggers()
                return True

        elif action.startswith("trigger/"):
            parts = action.split('/')
            trigger_name = parts[1]
            trigger_action = parts[2]

            msg = QApplication.translate("DBManagerPlugin", "Do you want to %s trigger %s?") % (
                trigger_action, trigger_name)
            QApplication.restoreOverrideCursor()
            try:
                if QMessageBox.question(None, QApplication.translate("DBManagerPlugin", "Table trigger"), msg,
                                        QMessageBox.Yes | QMessageBox.No) == QMessageBox.No:
                    return False
            finally:
                QApplication.setOverrideCursor(Qt.WaitCursor)

            if trigger_action == "delete":
                self.emitAboutToChange()
                self.database().connector.deleteTableTrigger(trigger_name, (self.schemaName(), self.name))
                self.refreshTriggers()
                return True

            elif trigger_action == "enable" or trigger_action == "disable":
                enable = trigger_action == "enable"
                self.emitAboutToChange()
                self.database().connector.enableTableTrigger(trigger_name, enable, (self.schemaName(), self.name))
                self.refreshTriggers()
                return True

        return False
开发者ID:boggins,项目名称:QGIS,代码行数:59,代码来源:plugin.py

示例3: deleteConstraint

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import question [as 别名]
    def deleteConstraint(self):
        """ delete a constraint """

        index = self.currentConstraint()
        if index == -1:
            return

        m = self.viewConstraints.model()
        constr = m.getObject(index)

        res = QMessageBox.question(self, self.tr("Are you sure"),
                                   self.tr("really delete constraint '%s'?") % constr.name,
                                   QMessageBox.Yes | QMessageBox.No)
        if res != QMessageBox.Yes:
            return

        QApplication.setOverrideCursor(Qt.WaitCursor)
        self.aboutToChangeTable.emit()
        try:
            constr.delete()
            self.populateViews()
        except BaseError as e:
            DlgDbError.showError(e, self)
            return
        finally:
            QApplication.restoreOverrideCursor()
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:28,代码来源:dlg_table_properties.py

示例4: runAction

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import question [as 别名]
    def runAction(self, action):
        action = unicode(action)

        if action.startswith("vacuumanalyze/"):
            if action == "vacuumanalyze/run":
                self.runVacuumAnalyze()
                return True

        elif action.startswith("rule/"):
            parts = action.split('/')
            rule_name = parts[1]
            rule_action = parts[2]

            msg = u"Do you want to %s rule %s?" % (rule_action, rule_name)

            QApplication.restoreOverrideCursor()

            try:
                if QMessageBox.question(None, self.tr("Table rule"), msg,
                                        QMessageBox.Yes | QMessageBox.No) == QMessageBox.No:
                    return False
            finally:
                QApplication.setOverrideCursor(Qt.WaitCursor)

            if rule_action == "delete":
                self.aboutToChange.emit()
                self.database().connector.deleteTableRule(rule_name, (self.schemaName(), self.name))
                self.refreshRules()
                return True

        return Table.runAction(self, action)
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:33,代码来源:plugin.py

示例5: execute

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import question [as 别名]
 def execute(self):
     reply = QMessageBox.question(
         None,
         self.tr('Confirmation', 'DeleteModelAction'),
         self.tr('Are you sure you want to delete this model?', 'DeleteModelAction'),
         QMessageBox.Yes | QMessageBox.No,
         QMessageBox.No)
     if reply == QMessageBox.Yes:
         os.remove(self.itemData.descriptionFile)
         self.toolbox.updateProvider('model')
开发者ID:Clayton-Davis,项目名称:QGIS,代码行数:12,代码来源:DeleteModelAction.py

示例6: clearLog

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import question [as 别名]
 def clearLog(self):
     reply = QMessageBox.question(self,
                                  self.tr('Confirmation'),
                                  self.tr('Are you sure you want to clear the history?'),
                                  QMessageBox.Yes | QMessageBox.No,
                                  QMessageBox.No
                                  )
     if reply == QMessageBox.Yes:
         ProcessingLog.clearLog()
         self.fillTree()
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:12,代码来源:HistoryDialog.py

示例7: closeEvent

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import question [as 别名]
 def closeEvent(self, evt):
     if self.hasChanged:
         ret = QMessageBox.question(self, self.tr('Unsaved changes'),
                                    self.tr('There are unsaved changes in script. Continue?'),
                                    QMessageBox.Yes | QMessageBox.No, QMessageBox.No
                                    )
         if ret == QMessageBox.Yes:
             evt.accept()
         else:
             evt.ignore()
     else:
         evt.accept()
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:14,代码来源:ScriptEditorDialog.py

示例8: execute

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import question [as 别名]
 def execute(self):
     reply = QMessageBox.question(None,
                                  self.tr('Confirmation', 'DeleteScriptAction'),
                                  self.tr('Are you sure you want to delete this script?',
                                          'DeleteScriptAction'),
                                  QMessageBox.Yes | QMessageBox.No,
                                  QMessageBox.No)
     if reply == QMessageBox.Yes:
         os.remove(self.itemData.descriptionFile)
         if self.scriptType == self.SCRIPT_PYTHON:
             self.toolbox.updateProvider('script')
         elif self.scriptType == self.SCRIPT_R:
             self.toolbox.updateProvider('r')
开发者ID:Clayton-Davis,项目名称:QGIS,代码行数:15,代码来源:DeleteScriptAction.py

示例9: removeActionSlot

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import question [as 别名]
    def removeActionSlot(self, item, action, parent):
        QApplication.restoreOverrideCursor()
        try:
            res = QMessageBox.question(parent, QApplication.translate("DBManagerPlugin", "hey!"),
                                       QApplication.translate("DBManagerPlugin",
                                                              "Really remove connection to %s?") % item.connectionName(),
                                       QMessageBox.Yes | QMessageBox.No)
            if res != QMessageBox.Yes:
                return
        finally:
            QApplication.setOverrideCursor(Qt.WaitCursor)

        item.remove()
开发者ID:boggins,项目名称:QGIS,代码行数:15,代码来源:plugin.py

示例10: emptyTableActionSlot

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import question [as 别名]
    def emptyTableActionSlot(self, item, action, parent):
        QApplication.restoreOverrideCursor()
        try:
            if not isinstance(item, Table) or item.isView:
                parent.infoBar.pushMessage(QApplication.translate("DBManagerPlugin", "Select a table to empty it."),
                                           QgsMessageBar.INFO, parent.iface.messageTimeout())
                return
            res = QMessageBox.question(parent, QApplication.translate("DBManagerPlugin", "hey!"),
                                       QApplication.translate("DBManagerPlugin",
                                                              "Really delete all items from table %s?") % item.name,
                                       QMessageBox.Yes | QMessageBox.No)
            if res != QMessageBox.Yes:
                return
        finally:
            QApplication.setOverrideCursor(Qt.WaitCursor)

        item.empty()
开发者ID:boggins,项目名称:QGIS,代码行数:19,代码来源:plugin.py

示例11: closeEvent

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import question [as 别名]
    def closeEvent(self, evt):
        settings = QSettings()
        settings.setValue("/Processing/splitterModeler", self.splitter.saveState())
        settings.setValue("/Processing/geometryModeler", self.saveGeometry())

        if self.hasChanged:
            ret = QMessageBox.question(
                self, self.tr('Unsaved changes'),
                self.tr('There are unsaved changes in model. Continue?'),
                QMessageBox.Yes | QMessageBox.No, QMessageBox.No)

            if ret == QMessageBox.Yes:
                evt.accept()
            else:
                evt.ignore()
        else:
            evt.accept()
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:19,代码来源:ModelerDialog.py

示例12: deleteSchemaActionSlot

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import question [as 别名]
    def deleteSchemaActionSlot(self, item, action, parent):
        QApplication.restoreOverrideCursor()
        try:
            if not isinstance(item, Schema):
                parent.infoBar.pushMessage(
                    QApplication.translate("DBManagerPlugin", "Select an empty schema for deletion."),
                    QgsMessageBar.INFO, parent.iface.messageTimeout())
                return
            res = QMessageBox.question(parent, QApplication.translate("DBManagerPlugin", "hey!"),
                                       QApplication.translate("DBManagerPlugin",
                                                              "Really delete schema %s?") % item.name,
                                       QMessageBox.Yes | QMessageBox.No)
            if res != QMessageBox.Yes:
                return
        finally:
            QApplication.setOverrideCursor(Qt.WaitCursor)

        item.delete()
开发者ID:boggins,项目名称:QGIS,代码行数:20,代码来源:plugin.py

示例13: runAction

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import question [as 别名]
    def runAction(self, action):
        action = unicode(action)

        if action.startswith("rows/"):
            if action == "rows/recount":
                self.refreshRowCount()
                return True
        elif action.startswith("index/"):
            parts = action.split('/')
            index_name = parts[1]
            index_action = parts[2]

            msg = QApplication.translate(
                "DBManagerPlugin",
                "Do you want to {} index {}?".format(
                    index_action, index_name))
            QApplication.restoreOverrideCursor()
            try:
                if QMessageBox.question(
                        None,
                        QApplication.translate(
                            "DBManagerPlugin", "Table Index"),
                        msg,
                        QMessageBox.Yes | QMessageBox.No) == QMessageBox.No:
                    return False
            finally:
                QApplication.setOverrideCursor(Qt.WaitCursor)

            if index_action == "rebuild":
                self.emitAboutToChange()
                self.database().connector.rebuildTableIndex(
                    (self.schemaName(), self.name), index_name)
                self.refreshIndexes()
                return True
        elif action.startswith(u"mview/"):
            if action == "mview/refresh":
                self.emitAboutToChange()
                self.database().connector.refreshMView(
                    (self.schemaName(), self.name))
                return True

        return Table.runAction(self, action)
开发者ID:boggins,项目名称:QGIS,代码行数:44,代码来源:plugin.py

示例14: add_tables

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import question [as 别名]
 def add_tables(self):
     if self.ui.tables.currentIndex() <= 0:
         return
     ag = self.ui.tables.currentText()
     #Retrieve Table Object from txt
     tableObj = [table for table in self.tables if table.name.upper() == ag.upper()]
     if len(tableObj) != 1:
         return  # No object with this name
     self.table = tableObj[0]
     if (ag in self.coltables):  # table already use
         response = QMessageBox.question(self, "Table already used", "Do you want to add table %s again?" % ag, QMessageBox.Yes | QMessageBox.No)
         if response == QMessageBox.No:
             return
     ag = self.table.quotedName()
     txt = self.ui.tab.text()
     if (txt is None) or (txt in ("", " ")):
         self.ui.tab.setText('%s' % ag)
     else:
         self.ui.tab.setText('%s, %s' % (txt, ag))
     self.ui.tables.setCurrentIndex(0)
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:22,代码来源:dlg_query_builder.py

示例15: createSpatialIndex

# 需要导入模块: from PyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt.QtWidgets.QMessageBox import question [as 别名]
    def createSpatialIndex(self):
        """ create spatial index for the geometry column """
        if self.table.type != self.table.VectorType:
            QMessageBox.information(self, self.tr("DB Manager"), self.tr("The selected table has no geometry"))
            return

        res = QMessageBox.question(self, self.tr("Create?"),
                                   self.tr("Create spatial index for field %s?") % self.table.geomColumn,
                                   QMessageBox.Yes | QMessageBox.No)
        if res != QMessageBox.Yes:
            return

        # TODO: first check whether the index doesn't exist already
        QApplication.setOverrideCursor(Qt.WaitCursor)
        self.aboutToChangeTable.emit()

        try:
            self.table.createSpatialIndex()
            self.populateViews()
        except BaseError as e:
            DlgDbError.showError(e, self)
            return
        finally:
            QApplication.restoreOverrideCursor()
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:26,代码来源:dlg_table_properties.py


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