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


Python QMessageBox.setText方法代码示例

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


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

示例1: _on_export_data

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import setText [as 别名]
    def _on_export_data(self):
        """
        Handler function that is called when the Export Data button is pressed
        """
        all_filters = ";;".join(['*.ecsv'])
        path, fmt = compat.getsavefilename(filters=all_filters)

        if path and fmt:
            try:
                plot_data_item = self.current_item
                self.export_data_item(plot_data_item, path, fmt)

                message_box = QMessageBox()
                message_box.setText("Data exported successfully.")
                message_box.setIcon(QMessageBox.Information)
                message_box.setInformativeText(
                    "Data set '{}' has been exported to '{}'".format(
                        plot_data_item.data_item.name, path))

                message_box.exec()
            except Exception as e:
                logging.error(e)

                message_box = QMessageBox()
                message_box.setText("Error exporting data set.")
                message_box.setIcon(QMessageBox.Critical)
                message_box.setInformativeText(
                    "{}\n{}".format(
                        sys.exc_info()[0], sys.exc_info()[1].__repr__()[:100])
                )

                message_box.exec()
开发者ID:nmearl,项目名称:specviz,代码行数:34,代码来源:workspace.py

示例2: _select_spectra_to_load

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import setText [as 别名]
    def _select_spectra_to_load(self, specs_by_name):

        selection_dialog = SpectrumSelection(self)
        selection_dialog.populate(specs_by_name.keys())
        selection_dialog.exec_()

        names_to_keep = selection_dialog.get_selected()

        if not names_to_keep:
            logging.warning('No spectra selected')

            message_box = QMessageBox()
            message_box.setText("No spectra were selected.")
            message_box.setIcon(QMessageBox.Warning)
            message_box.setInformativeText('No data has been loaded.')
            message_box.exec()

            return {}

        to_load = OrderedDict()
        for name, spectrum in specs_by_name.items():
            if name in names_to_keep:
                to_load[name] = spectrum

        return to_load
开发者ID:nmearl,项目名称:specviz,代码行数:27,代码来源:workspace.py

示例3: validate_password

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import setText [as 别名]
    def validate_password(self):
        """
        If the widget is ```passwordProtected```, this method will propmt
        the user for the correct password.

        Returns
        -------
        bool
            True in case the password was correct of if the widget is not
            password protected.
        """
        if not self._password_protected:
            return True

        pwd, ok = QInputDialog().getText(None, "Authentication", "Please enter your password:",
                                         QLineEdit.Password, "")
        pwd = str(pwd)
        if not ok or pwd == "":
            return False

        sha = hashlib.sha256()
        sha.update(pwd.encode())
        pwd_encrypted = sha.hexdigest()
        if pwd_encrypted != self._protected_password:
            msg = QMessageBox()
            msg.setIcon(QMessageBox.Critical)
            msg.setText("Invalid password.")
            msg.setWindowTitle("Error")
            msg.setStandardButtons(QMessageBox.Ok)
            msg.setDefaultButton(QMessageBox.Ok)
            msg.setEscapeButton(QMessageBox.Ok)
            msg.exec_()
            return False
        return True
开发者ID:slaclab,项目名称:pydm,代码行数:36,代码来源:pushbutton.py

示例4: dialog

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import setText [as 别名]
def dialog(title, text, icon, setting=None, default=None):

    if not getattr(settings, setting.upper()):
        return True

    check = QCheckBox()
    check.setText('Dont show this message again (can be reset via the preferences)')

    info = QMessageBox()
    info.setIcon(icon)
    info.setText(title)
    info.setInformativeText(text)
    info.setCheckBox(check)
    info.setStandardButtons(info.Cancel | info.Ok)
    if default == 'Cancel':
        info.setDefaultButton(info.Cancel)

    result = info.exec_()

    if result == info.Cancel:
        return False

    if check.isChecked():
        setattr(settings, setting.upper(), False)
        save_settings()

    return True
开发者ID:glue-viz,项目名称:glue,代码行数:29,代码来源:dialogs.py

示例5: show_error_message

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import setText [as 别名]
def show_error_message(message, title, parent=None):

    box = QMessageBox(parent=parent)
    box.setIcon(QMessageBox.Warning)
    box.setText(message)
    box.setWindowTitle(title)
    box.setStandardButtons(QMessageBox.Ok)
    box.exec_()
开发者ID:spacetelescope,项目名称:cube-tools,代码行数:10,代码来源:common.py

示例6: show_compatibility_message

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import setText [as 别名]
 def show_compatibility_message(self, message):
     """Show compatibility message."""
     messageBox = QMessageBox(self)
     messageBox.setWindowModality(Qt.NonModal)
     messageBox.setAttribute(Qt.WA_DeleteOnClose)
     messageBox.setWindowTitle('Compatibility Check')
     messageBox.setText(message)
     messageBox.setStandardButtons(QMessageBox.Ok)
     messageBox.show()
开发者ID:cfanpc,项目名称:spyder,代码行数:11,代码来源:plugins.py

示例7: display_message_box

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import setText [as 别名]
 def display_message_box(self, title, message, details):
     msg = QMessageBox(self)
     msg.setIcon(QMessageBox.Warning)
     msg.setText(message)
     msg.setWindowTitle(title)
     msg.setDetailedText(details)
     msg.setStandardButtons(QMessageBox.Ok)
     msg.setDefaultButton(QMessageBox.Ok)
     msg.setEscapeButton(QMessageBox.Ok)
     msg.exec_()
开发者ID:mantidproject,项目名称:mantid,代码行数:12,代码来源:errorreport.py

示例8: permission_box_to_prepend_import

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import setText [as 别名]
def permission_box_to_prepend_import():
    msg_box = QMessageBox()
    msg_box.setWindowTitle("Mantid Workbench")
    msg_box.setWindowIcon(QIcon(':/images/MantidIcon.ico'))
    msg_box.setText("It looks like this python file uses a Mantid "
                    "algorithm but does not import the Mantid API.")
    msg_box.setInformativeText("Would you like to add a line to import "
                               "the Mantid API?")
    msg_box.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
    msg_box.setDefaultButton(QMessageBox.Yes)
    permission = msg_box.exec_()
    if permission == QMessageBox.Yes:
        return True
    return False
开发者ID:mantidproject,项目名称:mantid,代码行数:16,代码来源:scriptcompatibility.py

示例9: display_load_data_error

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import setText [as 别名]
    def display_load_data_error(self, exp):
        """
        Display error message box when attempting to load a data set.

        Parameters
        ----------
        exp : str
            Error text.
        """
        message_box = QMessageBox()
        message_box.setText("Error loading data set.")
        message_box.setIcon(QMessageBox.Critical)
        message_box.setInformativeText(str(exp))
        message_box.exec()
开发者ID:nmearl,项目名称:specviz,代码行数:16,代码来源:workspace.py

示例10: show_mongo_query_help

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import setText [as 别名]
    def show_mongo_query_help(self):
        "Launch a Message Box with instructions for custom queries."
        msg = QMessageBox()
        msg.setIcon(QMessageBox.Information)
        msg.setText("For advanced search capability, enter a valid Mongo query.")
        msg.setInformativeText("""
Examples:

{'plan_name': 'scan'}
{'proposal': 1234},
{'$and': ['proposal': 1234, 'sample_name': 'Ni']}
""")
        msg.setWindowTitle("Custom Mongo Query")
        msg.setStandardButtons(QMessageBox.Ok)
        msg.exec_()
开发者ID:CJ-Wright,项目名称:bluesky-browser,代码行数:17,代码来源:search.py

示例11: save_list_to_file

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import setText [as 别名]
 def save_list_to_file(self):
     filename, filters = QFileDialog.getSaveFileName(self,
                                                     "Save connection list",
                                                     "",
                                                     "Text Files (*.txt)")
     try:
         with open(filename, "w") as f:
             for conn in self.table_view.model().connections:
                 f.write(
                     "{p}://{a}\n".format(p=conn.protocol, a=conn.address))
         self.save_status_label.setText("File saved to {}".format(filename))
     except Exception as e:
         msgBox = QMessageBox()
         msgBox.setText("Couldn't save connection list to file.")
         msgBox.setInformativeText("Error: {}".format(str(e)))
         msgBox.setStandardButtons(QMessageBox.Ok)
         msgBox.exec_()
开发者ID:slaclab,项目名称:pydm,代码行数:19,代码来源:connection_inspector.py

示例12: on_exception

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import setText [as 别名]
    def on_exception(self, exception):
        """
        Called when the `QThread` runs into an exception.
        Parameters
        ----------
        exception : Exception
            The Exception that interrupted the `QThread`.
        """
        self.smooth_button.setEnabled(True)
        self.cancel_button.setEnabled(True)

        info_box = QMessageBox(parent=self)
        info_box.setWindowTitle("Smoothing Error")
        info_box.setIcon(QMessageBox.Critical)
        info_box.setText(str(exception))
        info_box.setStandardButtons(QMessageBox.Ok)
        info_box.show()
开发者ID:nmearl,项目名称:specviz,代码行数:19,代码来源:smoothing_dialog.py

示例13: _on_change_color

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import setText [as 别名]
    def _on_change_color(self):
        """
        Listens for color changed events in plot windows, gets the currently
        selected item in the data list view, and changes the stored color
        value.
        """
        # If there is no currently selected rows, raise an error
        if self.current_item is None:
            message_box = QMessageBox()
            message_box.setText("No item selected, cannot change color.")
            message_box.setIcon(QMessageBox.Warning)
            message_box.setInformativeText(
                "There is currently no item selected. Please select an item "
                "before changing its plot color.")

            message_box.exec()
            return

        color = QColorDialog.getColor(options=QColorDialog.ShowAlphaChannel)

        if color.isValid():
            self.current_item.color = color.toRgb()
            self.color_changed.emit(self.current_item, self.current_item.color)
开发者ID:nmearl,项目名称:specviz,代码行数:25,代码来源:plotting.py

示例14: confirm_dialog

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import setText [as 别名]
    def confirm_dialog(self):
        """
        Show the confirmation dialog with the proper message in case
        ```showConfirmMessage``` is True.

        Returns
        -------
        bool
            True if the message was confirmed or if ```showCofirmMessage```
            is False.
        """

        if self._show_confirm_dialog:
            if self._confirm_message == "":
                self._confirm_message = PyDMPushButton.DEFAULT_CONFIRM_MESSAGE
            msg = QMessageBox()
            msg.setIcon(QMessageBox.Question)
            msg.setText(self._confirm_message)
            msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
            msg.setDefaultButton(QMessageBox.No)
            ret = msg.exec_()
            if ret == QMessageBox.No:
                return False
        return True
开发者ID:slaclab,项目名称:pydm,代码行数:26,代码来源:pushbutton.py

示例15: show

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import setText [as 别名]
    def show(self):
        """
        Parses the current plot window information and displays the unit change
        dialog with the appropriate available units to which the current
        plot's units can be changed.
        """
        # If there is no plot item, don't even try to process unit info
        if self.hub.plot_item is None or len(self.hub.visible_plot_items) == 0:
            message_box = QMessageBox()
            message_box.setText("No item plotted, cannot parse unit information.")
            message_box.setIcon(QMessageBox.Warning)
            message_box.setInformativeText(
                "There is currently no items plotted. Please plot an item "
                "before changing unit.")

            message_box.exec_()
            return

        # Prevents duplicate units from showing up each time this is executed
        self.ui.comboBox_units.clear()
        self.ui.comboBox_spectral.clear()

        # If the units in PlotWidget are not set, do not allow the user to click the OK button
        if not self.hub.plot_widget.data_unit:
            self.ui.comboBox_units.setEnabled(False)

        if not self.hub.plot_widget.spectral_axis_unit:
            self.ui.comboBox_spectral.setEnabled(False)

        if not (self.hub.plot_widget.data_unit or self.hub.plot_widget.spectral_axis_unit):
            self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)

        # Gets all possible conversions from current spectral_axis_unit
        self.spectral_axis_unit_equivalencies = u.Unit(
            self.hub.data_item.spectral_axis.unit).find_equivalent_units(
                equivalencies=u.spectral())

        # Gets all possible conversions for flux from current spectral axis and corresponding units
        # np.sum for spectral_axis so that it does not return a Quantity with zero scale
        self.data_unit_equivalencies = u.Unit(
            self.hub.plot_widget.data_unit).find_equivalent_units(
                equivalencies=u.spectral_density(np.sum(self.hub.data_item.spectral_axis)), include_prefix_units=False)

        # Current data unit and spectral axis unit
        self.current_data_unit = self.hub.plot_widget.data_unit
        self.current_spectral_axis_unit = self.hub.plot_widget.spectral_axis_unit

        # Add current spectral axis units to equivalencies
        if u.Unit(self.hub.plot_widget.spectral_axis_unit) not in self.spectral_axis_unit_equivalencies:
            self.spectral_axis_unit_equivalencies.append(u.Unit(self.hub.plot_widget.spectral_axis_unit))

        # Add original spectral axis units to equivalencies
        if u.Unit(self.hub.data_item.spectral_axis.unit) not in self.spectral_axis_unit_equivalencies:
            self.spectral_axis_unit_equivalencies.append(u.Unit(self.hub.data_item.spectral_axis.unit))

        # Add current data units to equivalencies
        if u.Unit(self.hub.plot_widget.data_unit) not in self.data_unit_equivalencies:
            self.data_unit_equivalencies.append(u.Unit(self.hub.plot_widget.data_unit))

        # Add original flux units to equivalencies
        if u.Unit(self.hub.data_item.flux.unit) not in self.data_unit_equivalencies:
            self.data_unit_equivalencies.append(u.Unit(self.hub.data_item.flux.unit))

        # Sort units by to_string()
        self.spectral_axis_unit_equivalencies = sorted(self.spectral_axis_unit_equivalencies, key=lambda x: x.to_string())
        self.data_unit_equivalencies = sorted(self.data_unit_equivalencies, key=lambda y: y.to_string())

        # Create lists with the "pretty" versions of unit names
        self.spectral_axis_unit_equivalencies_titles = [
            u.Unit(unit).name
            if u.Unit(unit) == u.Unit("Angstrom")
            else u.Unit(unit).long_names[0].title() if (hasattr(u.Unit(unit), "long_names") and len(u.Unit(unit).long_names) > 0)
            else u.Unit(unit).to_string()
            for unit in self.spectral_axis_unit_equivalencies]
        self.data_unit_equivalencies_titles = [
            u.Unit(unit).name
            if u.Unit(unit) == u.Unit("Angstrom")
            else u.Unit(unit).long_names[0].title() if (hasattr(u.Unit(unit), "long_names") and len(u.Unit(unit).long_names) > 0)
            else u.Unit(unit).to_string()
            for unit in self.data_unit_equivalencies]

        # This gives the user the option to use their own units. These units are checked by u.Unit()
        # and PlotDataItem.is_spectral_axis_unit_compatible(spectral_axis_unit) and
        # PlotDataItem.is_data_unit_compatible(data_unit)
        self.spectral_axis_unit_equivalencies_titles.append("Custom")
        self.data_unit_equivalencies_titles.append("Custom")

        self.setup_ui()
        self.setup_connections()

        super().show()
开发者ID:nmearl,项目名称:specviz,代码行数:93,代码来源:unit_change_dialog.py


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