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


Python QMessageBox.warning方法代码示例

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


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

示例1: get_table

# 需要导入模块: from AnyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from AnyQt.QtWidgets.QMessageBox import warning [as 别名]
    def get_table(self):
        curIdx = self.tablecombo.currentIndex()
        if curIdx <= 0:
            if self.database_desc:
                self.database_desc["Table"] = "(None)"
            self.data_desc_table = None
            return

        if self.tablecombo.itemText(curIdx) != "Custom SQL":
            self.table = self.tables[self.tablecombo.currentIndex()]
            self.database_desc["Table"] = self.table
            if "Query" in self.database_desc:
                del self.database_desc["Query"]
            what = self.table
        else:
            what = self.sql = self.sqltext.toPlainText()
            self.table = "Custom SQL"
            if self.materialize:
                import psycopg2
                if not self.materialize_table_name:
                    self.Error.connection(
                        "Specify a table name to materialize the query")
                    return
                try:
                    with self.backend.execute_sql_query("DROP TABLE IF EXISTS " +
                                                        self.materialize_table_name):
                        pass
                    with self.backend.execute_sql_query("CREATE TABLE " +
                                                        self.materialize_table_name +
                                                        " AS " + self.sql):
                        pass
                    with self.backend.execute_sql_query("ANALYZE " + self.materialize_table_name):
                        pass
                except (psycopg2.ProgrammingError, BackendError) as ex:
                    self.Error.connection(str(ex))
                    return

        try:
            table = SqlTable(dict(host=self.host,
                                  port=self.port,
                                  database=self.database,
                                  user=self.username,
                                  password=self.password),
                             what,
                             backend=type(self.backend),
                             inspect_values=False)
        except BackendError as ex:
            self.Error.connection(str(ex))
            return

        self.Error.connection.clear()

        sample = False

        if table.approx_len() > LARGE_TABLE and self.guess_values:
            confirm = QMessageBox(self)
            confirm.setIcon(QMessageBox.Warning)
            confirm.setText("Attribute discovery might take "
                            "a long time on large tables.\n"
                            "Do you want to auto discover attributes?")
            confirm.addButton("Yes", QMessageBox.YesRole)
            no_button = confirm.addButton("No", QMessageBox.NoRole)
            sample_button = confirm.addButton("Yes, on a sample",
                                              QMessageBox.YesRole)
            confirm.exec()
            if confirm.clickedButton() == no_button:
                self.guess_values = False
            elif confirm.clickedButton() == sample_button:
                sample = True

        self.Information.clear()
        if self.guess_values:
            QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
            if sample:
                s = table.sample_time(1)
                domain = s.get_domain(inspect_values=True)
                self.Information.data_sampled()
            else:
                domain = table.get_domain(inspect_values=True)
            QApplication.restoreOverrideCursor()
            table.domain = domain

        if self.download:
            if table.approx_len() > MAX_DL_LIMIT:
                QMessageBox.warning(
                    self, 'Warning', "Data is too big to download.\n"
                    "Consider using the Data Sampler widget to download "
                    "a sample instead.")
                self.download = False
            elif table.approx_len() > AUTO_DL_LIMIT:
                confirm = QMessageBox.question(
                    self, 'Question', "Data appears to be big. Do you really "
                                      "want to download it to local memory?",
                    QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
                if confirm == QMessageBox.No:
                    self.download = False
        if self.download:
            table.download_data(MAX_DL_LIMIT)
            table = Table(table)

#.........这里部分代码省略.........
开发者ID:kernc,项目名称:orange3,代码行数:103,代码来源:owsql.py

示例2: __init__

# 需要导入模块: from AnyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from AnyQt.QtWidgets.QMessageBox import warning [as 别名]
    def __init__(self, parent=None, *, mime=None, image=None):
        QDialog.__init__(self, parent)
        self.setupUi(self)
        self._backend = None
        self._backend_controls = {}
        self._label_anonymous = self.tr('Anonymous')
        self._label_select_login = self.tr('Select Login')
        self._available_backends = []

        data = None
        file_name = None
        if image:
            self._share_type = Bi.Image
            data = image
        elif mime:
            if mime.hasImage():
                self._share_type = Bi.Image
                data = mime.imageData()
            elif mime.hasUrls():
                urls = mime.urls()
                if len(urls) == 1:
                    file_path = os.path.realpath(urls[0].toLocalFile())
                    if not os.path.isfile(file_path):
                        raise ValueError(self.tr('Directories can not be shared'))
                    file_size = os.path.getsize(file_path)
                    file_name = os.path.basename(file_path)

                    if file_size > const.BIG_FILE_WARNING_SIZE:
                        file_name = os.path.basename(file_path)
                        nice_size = format_size(file_size)
                        result = QMessageBox.warning(self, self.tr('Warning'),
                                                     self.tr('File "{file_name}" {nice_size}.\n'
                                                             'Are you sure you want to continue?').format(**locals()),
                                                     QMessageBox.Yes | QMessageBox.Abort)
                        if result == QMessageBox.Abort:
                            QTimer.singleShot(0, self.reject)
                            return

                    if file_has_extension(file_path, ('png', 'jpg', 'jpeg', 'bmp', 'gif')):
                        image = QPixmap(file_path)
                    else:
                        image = None
                    if not image or image.isNull():
                        data = read_text_from_file(file_path)
                        if data:
                            self._share_type = Bi.Text
                        else:
                            self._share_type = Bi.File
                            data = file_path
                    else:
                        self._share_type = Bi.Image
                        data = image
                else:
                    raise ValueError(self.tr('Can not share more than one file'))

            elif mime.hasText():
                self._share_type = Bi.Text
                data = mime.text()
        else:
            raise RuntimeError()

        if not data:
            raise ValueError(self.tr('There is no content in your clipboard.\nCopy something in order to share it.'))

        if self._share_type == Bi.Image:
            if not file_name:
                file_name = '{}-{}.png'.format('screenshot' if image else 'image', int(time()))
            if data.width() > self.image_preview.width() or data.height() > self.image_preview.height():
                preview = data.scaled(self.image_preview.size(), Qt.KeepAspectRatio)
            else:
                preview = data
            if isinstance(preview, QImage):
                preview = QPixmap.fromImage(preview)
            self.image_preview.setPixmap(preview)
            self.preview_stack.setCurrentIndex(0)
            buf = QBuffer()
            data.save(buf, 'png', 100)
            data = buf.data().data()
        elif self._share_type == Bi.Text:
            if not file_name:
                file_name = 'file-{}.txt'.format(int(time()))
            self.text_preview.setPlainText(dedent_text_and_truncate(data, 128))
            self.preview_stack.setCurrentIndex(1)
        elif self._share_type == Bi.File:
            if not file_name:
                file_name = 'file-{}.bin'.format(int(time()))
            self.text_preview.setPlainText(self.tr('No preview available'))
            self.preview_stack.setCurrentIndex(1)

        self._file_name = file_name
        self._data = data

        self.populate_backends()

        self.share.pressed.connect(self.share_item)
        self.add_login.pressed.connect(self.on_add_login)
        self.logout.pressed.connect(self.logout_selected)
        self.login_list.currentIndexChanged.connect(self.select_login)

        min_height = self.backend_selector.minimumSizeHint().height()
#.........这里部分代码省略.........
开发者ID:rokups,项目名称:paste2box,代码行数:103,代码来源:share.py


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