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


Python QtWidgets.QMessageBox类代码示例

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


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

示例1: setData

    def setData(self, index, value, role=Qt.EditRole, change_type=None):
        """Cell content change"""
        column = index.column()
        row = index.row()

        if change_type is not None:
            try:
                value = self.data(index, role=Qt.DisplayRole)
                val = from_qvariant(value, str)
                if change_type is bool:
                    val = bool_false_check(val)
                self.df.iloc[row, column - 1] = change_type(val)
            except ValueError:
                self.df.iloc[row, column - 1] = change_type('0')
        else:
            val = from_qvariant(value, str)
            current_value = self.get_value(row, column-1)
            if isinstance(current_value, bool):
                val = bool_false_check(val)
            supported_types = (bool,) + REAL_NUMBER_TYPES + COMPLEX_NUMBER_TYPES
            if (isinstance(current_value, supported_types) or 
                    is_text_string(current_value)):
                try:
                    self.df.iloc[row, column-1] = current_value.__class__(val)
                except ValueError as e:
                    QMessageBox.critical(self.dialog, "Error",
                                         "Value error: %s" % str(e))
                    return False
            else:
                QMessageBox.critical(self.dialog, "Error",
                                     "The type of the cell is not a supported "
                                     "type")
                return False
        self.max_min_col_update()
        return True
开发者ID:rlaverde,项目名称:spyder,代码行数:35,代码来源:dataframeeditor.py

示例2: _scatter_artist

 def _scatter_artist(self, axes, state, layer=None, layer_state=None):
     if len(self._layer_artist_container) == 0:
         QMessageBox.critical(self, "Error", "Can only add a scatter plot "
                              "overlay once an image is present",
                              buttons=QMessageBox.Ok)
         return None
     return ScatterLayerArtist(axes, state, layer=layer, layer_state=None)
开发者ID:sergiopasra,项目名称:glue,代码行数:7,代码来源:data_viewer.py

示例3: sort

    def sort(self, column, order=Qt.AscendingOrder):
        """Overriding sort method"""
        if self.complex_intran is not None:
            if self.complex_intran.any(axis=0).iloc[column-1]:
                QMessageBox.critical(self.dialog, "Error",
                                     "TypeError error: no ordering "
                                     "relation is defined for complex numbers")
                return False
        try:
            ascending = order == Qt.AscendingOrder
            if column > 0:
                try:
                    self.df.sort_values(by=self.df.columns[column-1],
                                        ascending=ascending, inplace=True,
                                        kind='mergesort')
                except AttributeError:
                    # for pandas version < 0.17
                    self.df.sort(columns=self.df.columns[column-1],
                                 ascending=ascending, inplace=True,
                                 kind='mergesort')
                self.update_df_index()
            else:
                self.df.sort_index(inplace=True, ascending=ascending)
                self.update_df_index()
        except TypeError as e:
            QMessageBox.critical(self.dialog, "Error",
                                 "TypeError error: %s" % str(e))
            return False

        self.reset()
        return True
开发者ID:rlaverde,项目名称:spyder,代码行数:31,代码来源:dataframeeditor.py

示例4: converter

    def converter(self, parent=None, convert_data=False):
        """
        Launch Converter GUI
        :param parent: application
        :param values:
            convert data values if True.
            Only displayed units if False.
        :return: ConvertFluxUnitGUI instance
        :raise: Exception: If wavelength info is missing
        """
        if self.wavelengths is None:
            message = "Could not launch conversion ui because" \
                      "wavelength information is missing."
            info = QMessageBox.critical(parent, "Error", message)
            raise Exception(message)

        if convert_data:
            message = "You are about to launch the data flux units converter. " \
                      "This will modify the actual values stored in components " \
                      "according to the unit conversions selected. If you would rather" \
                      " change the displayed units, please select the Convert" \
                      " Displayed Units option."
            info = QMessageBox.warning(parent, "Info", message)

        if hasattr(u.spectral_density, "pixel_area"):
            u.spectral_density.pixel_area = self.pixel_area

        ex = ConvertFluxUnitGUI(self, parent, convert_data)
        return ex
开发者ID:spacetelescope,项目名称:cube-tools,代码行数:29,代码来源:flux_units.py

示例5: launch_error_message

    def launch_error_message(self, error_type, error=None):
        """Launch a message box with a predefined error message.

        Parameters
        ----------
        error_type : int [CLOSE_ERROR, RESET_ERROR, RESTART_ERROR]
            Possible error codes when restarting/reseting spyder.
        error : Exception
            Actual Python exception error caught.
        """
        messages = {CLOSE_ERROR: _("It was not possible to close the previous "
                                   "Spyder instance.\nRestart aborted."),
                    RESET_ERROR: _("Spyder could not reset to factory "
                                   "defaults.\nRestart aborted."),
                    RESTART_ERROR: _("It was not possible to restart Spyder.\n"
                                     "Operation aborted.")}
        titles = {CLOSE_ERROR: _("Spyder exit error"),
                  RESET_ERROR: _("Spyder reset error"),
                  RESTART_ERROR: _("Spyder restart error")}

        if error:
            e = error.__repr__()
            message = messages[error_type] + "\n\n{0}".format(e)
        else:
            message = messages[error_type]

        title = titles[error_type]
        self.splash.hide()
        QMessageBox.warning(self, title, message, QMessageBox.Ok)
        raise RuntimeError(message)
开发者ID:jitseniesen,项目名称:spyder,代码行数:30,代码来源:restart.py

示例6: help

 def help(self):
     """Help on Spyder console"""
     QMessageBox.about(
         self,
         _("Help"),
         """<b>%s</b>
                       <p><i>%s</i><br>    edit foobar.py
                       <p><i>%s</i><br>    xedit foobar.py
                       <p><i>%s</i><br>    run foobar.py
                       <p><i>%s</i><br>    clear x, y
                       <p><i>%s</i><br>    !ls
                       <p><i>%s</i><br>    object?
                       <p><i>%s</i><br>    result = oedit(object)
                       """
         % (
             _("Shell special commands:"),
             _("Internal editor:"),
             _("External editor:"),
             _("Run script:"),
             _("Remove references:"),
             _("System commands:"),
             _("Python help:"),
             _("GUI-based editor:"),
         ),
     )
开发者ID:jitseniesen,项目名称:spyder,代码行数:25,代码来源:internalshell.py

示例7: delete_project

 def delete_project(self):
     """
     Delete the current project without deleting the files in the directory.
     """
     if self.current_active_project:
         self.switch_to_plugin()
         path = self.current_active_project.root_path
         buttons = QMessageBox.Yes | QMessageBox.No
         answer = QMessageBox.warning(
             self,
             _("Delete"),
             _("Do you really want to delete <b>{filename}</b>?<br><br>"
               "<b>Note:</b> This action will only delete the project. "
               "Its files are going to be preserved on disk."
               ).format(filename=osp.basename(path)),
             buttons)
         if answer == QMessageBox.Yes:
             try:
                 self.close_project()
                 shutil.rmtree(osp.join(path, '.spyproject'))
             except EnvironmentError as error:
                 QMessageBox.critical(
                     self,
                     _("Project Explorer"),
                     _("<b>Unable to delete <i>{varpath}</i></b>"
                       "<br><br>The error message was:<br>{error}"
                       ).format(varpath=path, error=to_text_string(error)))
开发者ID:impact27,项目名称:spyder,代码行数:27,代码来源:plugin.py

示例8: mirror_navi

    def mirror_navi(self, uisignals=None, shared_nav=False):
        # Select signals
        if uisignals is None:
            uisignals = self.ui.get_selected_wrappers()
        if len(uisignals) < 2:
            mb = QMessageBox(QMessageBox.Information, tr("Select two or more"),
                             tr("You need to select two or more signals" +
                                " to mirror"), QMessageBox.Ok)
            mb.exec_()
            return

        signals = [s.signal for s in uisignals]

        # hyperspy closes, and then recreates figures when mirroring
        # the navigators. To keep UI from flickering, we suspend updates.
        # SignalWrapper also saves and then restores window geometry
        self.ui.setUpdatesEnabled(False)
        try:
            if shared_nav:
                navs = ["auto"]
                navs.extend([None] * (len(signals)-1))
                hyperspy.utils.plot.plot_signals(signals, sync=True,
                                                 navigator_list=navs)
            else:
                hyperspy.utils.plot.plot_signals(signals, sync=True)
        finally:
            self.ui.setUpdatesEnabled(True)    # Continue updating UI
开发者ID:hyperspy,项目名称:hyperspyUI,代码行数:27,代码来源:mirrorplot.py

示例9: change_format

    def change_format(self):
        """
        Ask user for display format for floats and use it.

        This function also checks whether the format is valid and emits
        `sig_option_changed`.
        """
        format, valid = QInputDialog.getText(self, _('Format'),
                                             _("Float formatting"),
                                             QLineEdit.Normal,
                                             self.dataModel.get_format())
        if valid:
            format = str(format)
            try:
                format % 1.1
            except:
                msg = _("Format ({}) is incorrect").format(format)
                QMessageBox.critical(self, _("Error"), msg)
                return
            if not format.startswith('%'):
                msg = _("Format ({}) should start with '%'").format(format)
                QMessageBox.critical(self, _("Error"), msg)
                return
            self.dataModel.set_format(format)
            self.sig_option_changed.emit('dataframe_format', format)
开发者ID:rlaverde,项目名称:spyder,代码行数:25,代码来源:dataframeeditor.py

示例10: _set_step

 def _set_step(self, step):
     """Proceed to a given step"""
     new_tab = self.tab_widget.currentIndex() + step
     assert new_tab < self.tab_widget.count() and new_tab >= 0
     if new_tab == self.tab_widget.count()-1:
         try:
             self.table_widget.open_data(self._get_plain_text(),
                                     self.text_widget.get_col_sep(),
                                     self.text_widget.get_row_sep(),
                                     self.text_widget.trnsp_box.isChecked(),
                                     self.text_widget.get_skiprows(),
                                     self.text_widget.get_comments())
             self.done_btn.setEnabled(True)
             self.done_btn.setDefault(True)
             self.fwd_btn.setEnabled(False)
             self.back_btn.setEnabled(True)
         except (SyntaxError, AssertionError) as error:
             QMessageBox.critical(self, _("Import wizard"),
                         _("<b>Unable to proceed to next step</b>"
                           "<br><br>Please check your entries."
                           "<br><br>Error message:<br>%s") % str(error))
             return
     elif new_tab == 0:
         self.done_btn.setEnabled(False)
         self.fwd_btn.setEnabled(True)
         self.back_btn.setEnabled(False)
     self._focus_tab(new_tab)
开发者ID:ShenggaoZhu,项目名称:spyder,代码行数:27,代码来源:importwizard.py

示例11: call_cutout

 def call_cutout(self):
     self.spec_path = self.spectra_user_input.text()
     if self.spec_path == "":
         self.spectra_user_input.setStyleSheet("background-color: rgba(255, 0, 0, 128);")
         info = QMessageBox.information(self, "Error", "Please provide directory containing NIRSpec spectra files.")
         return
     else:
         self.spectra_user_input.setStyleSheet("")
         if not os.path.isdir(self.spec_path):
             self.spectra_user_input.setStyleSheet("background-color: rgba(255, 0, 0, 128);")
             info = QMessageBox.information(self, "Error", "Broken path:\n\n"+self.spec_path)
             return
     if self.CutoutTool is not None:
         if self.CutoutTool.isVisible():
             info = QMessageBox.information(self, "Status",
                 "Error: Cutout tool is still running.")
             self.CutoutTool.raise_()
             return
         else:
             self.CutoutTool = None
     try:
         self.CutoutTool = NIRSpecCutoutTool(self.parent.session,
             parent=self, spec_path=self.spec_path, TableGen=self)
     except Exception as e:
         info = QMessageBox.critical(self, "Error", "Cutout tool failed: "+str(e))
开发者ID:spacetelescope,项目名称:mosviz,代码行数:25,代码来源:nirspec_table_ui.py

示例12: save_register_new_loader

    def save_register_new_loader(self, filename):
        """
        Save and register new loader file to specutils loader directory.
        If a loader with the current name already exists it will be
        deleted.

        Parameters
        ----------
        filename: str
          Loader filename. If filename does not end in ".py", ".py" will be appended
          to the end of the string.
        """
        filename = "{}.py".format(filename) if not filename.endswith(".py") else filename

        string = self.as_new_loader()

        with open(filename, 'w') as f:
            f.write(string)

        # If a loader by this name exists, delete it
        if self.new_loader_dict['name'] in registry.get_formats()['Format']:
            registry.unregister_reader(self.new_loader_dict['name'], Spectrum1D)
            registry.unregister_identifier(self.new_loader_dict['name'], Spectrum1D)

        # Add new loader to registry
        spec = importlib.util.spec_from_file_location(os.path.basename(filename)[:-3], filename)
        mod = importlib.util.module_from_spec(spec)
        spec.loader.exec_module(mod)

        QMessageBox.information(self,
                                "Loader saved successful.",
                                "Custom loader was saved successfully.")
开发者ID:nmearl,项目名称:specviz,代码行数:32,代码来源:loader_wizard.py

示例13: set_user_env

 def set_user_env(reg, parent=None):
     """Set HKCU (current user) environment variables"""
     reg = listdict2envdict(reg)
     types = dict()
     key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, "Environment")
     for name in reg:
         try:
             _x, types[name] = winreg.QueryValueEx(key, name)
         except WindowsError:
             types[name] = winreg.REG_EXPAND_SZ
     key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, "Environment", 0,
                          winreg.KEY_SET_VALUE)
     for name in reg:
         winreg.SetValueEx(key, name, 0, types[name], reg[name])
     try:
         from win32gui import SendMessageTimeout
         from win32con import (HWND_BROADCAST, WM_SETTINGCHANGE,
                               SMTO_ABORTIFHUNG)
         SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0,
                            "Environment", SMTO_ABORTIFHUNG, 5000)
     except ImportError:
         QMessageBox.warning(parent, _("Warning"),
                     _("Module <b>pywin32 was not found</b>.<br>"
                       "Please restart this Windows <i>session</i> "
                       "(not the computer) for changes to take effect."))
开发者ID:ChunHungLiu,项目名称:spyder,代码行数:25,代码来源:environ.py

示例14: action_released

    def action_released(self):
        """ """
        model = self.source_model
        model_index = self._model_index_clicked

        if model_index:
            column = model_index.column()

            if column == const.INSTALL and model.is_removable(model_index):
                column = const.REMOVE
            self.source_model.update_row_icon(model_index.row(), column)

            if self.valid:
                row_data = self.source_model.row(model_index.row())
                type_ = row_data[const.PACKAGE_TYPE]
                name = row_data[const.NAME]
                versions = self.source_model.get_package_versions(name)
                version = self.source_model.get_package_version(name)

                if type_ == const.CONDA:
                    self._parent._run_action(name, column, version, versions)
                elif type_ == const.PIP:
                    QMessageBox.information(self, "Remove pip package: "
                                            "{0}".format(name),
                                            "This functionality is not yet "
                                            "available.")
                else:
                    pass
开发者ID:ccordoba12,项目名称:conda-manager,代码行数:28,代码来源:table.py

示例15: save_loader_script

    def save_loader_script(self, event=None, output_directory=None):
        """
        oputput_directory parameter is strictly for use in tests.
        """

        if not self.save_loader_check():
            return

        specutils_dir = os.path.join(os.path.expanduser('~'), '.specutils')

        if not os.path.exists(specutils_dir):
            os.mkdir(specutils_dir)

        loader_name = self.ui.loader_name.text()

        # If the loader name already exists in the registry, raise a warning
        # and ask the user to pick another name
        if loader_name in registry.get_formats(Spectrum1D, 'Read')['Format']:
            QMessageBox.information(
                self,
                "Loader name already exists.",
                "A loader with the name '{}' already exists in the registry. "
                "Please choose a different name.".format(loader_name))

            return

        out_path = os.path.join(specutils_dir, loader_name)

        filename = compat.getsavefilename(parent=self,
                                          caption='Export loader to .py file',
                                          basedir=out_path)[0]
        if filename == '':
            return

        self.save_register_new_loader(filename)
开发者ID:nmearl,项目名称:specviz,代码行数:35,代码来源:loader_wizard.py


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