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


Python QMessageBox.critical方法代码示例

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


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

示例1: chdir

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import critical [as 别名]
 def chdir(self, directory=None, browsing_history=False):
     """Set directory as working directory"""
     if directory is not None:
         directory = osp.abspath(to_text_string(directory))
     if browsing_history:
         directory = self.history[self.histindex]
     elif directory in self.history:
         self.histindex = self.history.index(directory)
     else:
         if self.histindex is None:
             self.history = []
         else:
             self.history = self.history[:self.histindex+1]
         if len(self.history) == 0 or \
            (self.history and self.history[-1] != directory):
             self.history.append(directory)
         self.histindex = len(self.history)-1
     directory = to_text_string(directory)
     if PY2:
         PermissionError = OSError
     try:
         os.chdir(directory)
         self.parent_widget.open_dir.emit(directory)
         self.refresh(new_path=directory, force_current=True)
     except PermissionError:
         QMessageBox.critical(self.parent_widget, "Error",
                              _("You don't have the right permissions to "
                                "open this directory"))
开发者ID:ShenggaoZhu,项目名称:spyder,代码行数:30,代码来源:explorer.py

示例2: delete_file

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import critical [as 别名]
 def delete_file(self, fname, multiple, yes_to_all):
     """Delete file"""
     if multiple:
         buttons = QMessageBox.Yes|QMessageBox.YesAll| \
                   QMessageBox.No|QMessageBox.Cancel
     else:
         buttons = QMessageBox.Yes|QMessageBox.No
     if yes_to_all is None:
         answer = QMessageBox.warning(self, _("Delete"),
                              _("Do you really want "
                                "to delete <b>%s</b>?"
                                ) % osp.basename(fname), buttons)
         if answer == QMessageBox.No:
             return yes_to_all
         elif answer == QMessageBox.Cancel:
             return False
         elif answer == QMessageBox.YesAll:
             yes_to_all = True
     try:
         if osp.isfile(fname):
             misc.remove_file(fname)
             self.parent_widget.removed.emit(fname)
         else:
             self.remove_tree(fname)
             self.parent_widget.removed_tree.emit(fname)
         return yes_to_all
     except EnvironmentError as error:
         action_str = _('delete')
         QMessageBox.critical(self, _("Project Explorer"),
                         _("<b>Unable to %s <i>%s</i></b>"
                           "<br><br>Error message:<br>%s"
                           ) % (action_str, fname, to_text_string(error)))
     return False
开发者ID:ShenggaoZhu,项目名称:spyder,代码行数:35,代码来源:explorer.py

示例3: start

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import critical [as 别名]
 def start(self):
     filename = to_text_string(self.filecombo.currentText())
     
     self.process = QProcess(self)
     self.process.setProcessChannelMode(QProcess.SeparateChannels)
     self.process.setWorkingDirectory(osp.dirname(filename))
     self.process.readyReadStandardOutput.connect(self.read_output)
     self.process.readyReadStandardError.connect(
                                       lambda: self.read_output(error=True))
     self.process.finished.connect(lambda ec, es=QProcess.ExitStatus:
                                   self.finished(ec, es))
     self.stop_button.clicked.connect(self.process.kill)
     
     self.output = ''
     self.error_output = ''
     
     plver = PYLINT_VER
     if plver is not None:
         if plver.split('.')[0] == '0':
             p_args = ['-i', 'yes']
         else:
             # Option '-i' (alias for '--include-ids') was removed in pylint
             # 1.0
             p_args = ["--msg-template='{msg_id}:{line:3d},"\
                       "{column}: {obj}: {msg}"]
         p_args += [osp.basename(filename)]
     else:
         p_args = [osp.basename(filename)]
     self.process.start(PYLINT_PATH, p_args)
     
     running = self.process.waitForStarted()
     self.set_running_state(running)
     if not running:
         QMessageBox.critical(self, _("Error"),
                              _("Process failed to start"))
开发者ID:ShenggaoZhu,项目名称:spyder,代码行数:37,代码来源:pylintgui.py

示例4: _set_step

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import critical [as 别名]
 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,代码行数:29,代码来源:importwizard.py

示例5: create_new_folder

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import critical [as 别名]
 def create_new_folder(self, current_path, title, subtitle, is_package):
     """Create new folder"""
     if current_path is None:
         current_path = ''
     if osp.isfile(current_path):
         current_path = osp.dirname(current_path)
     name, valid = QInputDialog.getText(self, title, subtitle,
                                        QLineEdit.Normal, "")
     if valid:
         dirname = osp.join(current_path, to_text_string(name))
         try:
             os.mkdir(dirname)
         except EnvironmentError as error:
             QMessageBox.critical(self, title,
                                  _("<b>Unable "
                                    "to create folder <i>%s</i></b>"
                                    "<br><br>Error message:<br>%s"
                                    ) % (dirname, to_text_string(error)))
         finally:
             if is_package:
                 fname = osp.join(dirname, '__init__.py')
                 try:
                     with open(fname, 'wb') as f:
                         f.write(to_binary_string('#'))
                     return dirname
                 except EnvironmentError as error:
                     QMessageBox.critical(self, title,
                                          _("<b>Unable "
                                            "to create file <i>%s</i></b>"
                                            "<br><br>Error message:<br>%s"
                                            ) % (fname,
                                                 to_text_string(error)))
开发者ID:ShenggaoZhu,项目名称:spyder,代码行数:34,代码来源:explorer.py

示例6: rename_file

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import critical [as 别名]
 def rename_file(self, fname):
     """Rename file"""
     path, valid = QInputDialog.getText(self, _('Rename'),
                           _('New name:'), QLineEdit.Normal,
                           osp.basename(fname))
     if valid:
         path = osp.join(osp.dirname(fname), to_text_string(path))
         if path == fname:
             return
         if osp.exists(path):
             if QMessageBox.warning(self, _("Rename"),
                      _("Do you really want to rename <b>%s</b> and "
                        "overwrite the existing file <b>%s</b>?"
                        ) % (osp.basename(fname), osp.basename(path)),
                      QMessageBox.Yes|QMessageBox.No) == QMessageBox.No:
                 return
         try:
             misc.rename_file(fname, path)
             self.parent_widget.renamed.emit(fname, path)
             return path
         except EnvironmentError as error:
             QMessageBox.critical(self, _("Rename"),
                         _("<b>Unable to rename file <i>%s</i></b>"
                           "<br><br>Error message:<br>%s"
                           ) % (osp.basename(fname), to_text_string(error)))
开发者ID:ShenggaoZhu,项目名称:spyder,代码行数:27,代码来源:explorer.py

示例7: setData

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import critical [as 别名]
    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,代码行数:37,代码来源:dataframeeditor.py

示例8: change_format

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import critical [as 别名]
    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,代码行数:27,代码来源:dataframeeditor.py

示例9: _scatter_artist

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import critical [as 别名]
 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,代码行数:9,代码来源:data_viewer.py

示例10: sort

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import critical [as 别名]
    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,代码行数:33,代码来源:dataframeeditor.py

示例11: save_data

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import critical [as 别名]
 def save_data(self, filename=None):
     """Save data"""
     if filename is None:
         filename = self.filename
         if filename is None:
             filename = getcwd()
         filename, _selfilter = getsavefilename(self, _("Save data"),
                                                filename,
                                                iofunctions.save_filters)
         if filename:
             self.filename = filename
         else:
             return False
     QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
     QApplication.processEvents()
     if self.is_internal_shell:
         wsfilter = self.get_internal_shell_filter('picklable',
                                                   check_all=True)
         namespace = wsfilter(self.shellwidget.interpreter.namespace).copy()
         error_message = iofunctions.save(namespace, filename)
     else:
         settings = self.get_view_settings()
         error_message = monitor_save_globals(self._get_sock(),
                                              settings, filename)
     QApplication.restoreOverrideCursor()
     QApplication.processEvents()
     if error_message is not None:
         QMessageBox.critical(self, _("Save data"),
                         _("<b>Unable to save current workspace</b>"
                           "<br><br>Error message:<br>%s") % error_message)
     self.save_button.setEnabled(self.filename is not None)
开发者ID:ChunHungLiu,项目名称:spyder,代码行数:33,代码来源:namespacebrowser.py

示例12: save_data

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import critical [as 别名]
    def save_data(self, filename=None):
        """Save data"""
        if filename is None:
            filename = self.filename
            if filename is None:
                filename = getcwd_or_home()
            filename, _selfilter = getsavefilename(self, _("Save data"),
                                                   filename,
                                                   iofunctions.save_filters)
            if filename:
                self.filename = filename
            else:
                return False
        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
        QApplication.processEvents()

        error_message = self.shellwidget.save_namespace(self.filename)
        self.shellwidget._kernel_reply = None

        QApplication.restoreOverrideCursor()
        QApplication.processEvents()
        if error_message is not None:
            QMessageBox.critical(self, _("Save data"),
                            _("<b>Unable to save current workspace</b>"
                              "<br><br>Error message:<br>%s") % error_message)
        self.save_button.setEnabled(self.filename is not None)
开发者ID:burrbull,项目名称:spyder,代码行数:28,代码来源:namespacebrowser.py

示例13: save_data

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import critical [as 别名]
    def save_data(self, filename=None):
        """Save data"""
        if filename is None:
            filename = self.filename
            if filename is None:
                filename = getcwd_or_home()
            filename, _selfilter = getsavefilename(self, _("Save data"),
                                                   filename,
                                                   iofunctions.save_filters)
            if filename:
                self.filename = filename
            else:
                return False
        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
        QApplication.processEvents()

        error_message = self.shellwidget.save_namespace(self.filename)
        self.shellwidget._kernel_reply = None

        QApplication.restoreOverrideCursor()
        QApplication.processEvents()
        if error_message is not None:
            if 'Some objects could not be saved:' in error_message:
                save_data_message = (
                    _('<b>Some objects could not be saved:</b>')
                    + '<br><br><code>{obj_list}</code>'.format(
                        obj_list=error_message.split(': ')[1]))
            else:
                save_data_message = _(
                    '<b>Unable to save current workspace</b>'
                    '<br><br>Error message:<br>') + error_message
            QMessageBox.critical(self, _("Save data"), save_data_message)
        self.save_button.setEnabled(self.filename is not None)
开发者ID:impact27,项目名称:spyder,代码行数:35,代码来源:namespacebrowser.py

示例14: delete_project

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import critical [as 别名]
 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,代码行数:29,代码来源:plugin.py

示例15: open_project

# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import critical [as 别名]
    def open_project(self, path=None, restart_consoles=True,
                     save_previous_files=True):
        """Open the project located in `path`"""
        if path is None:
            basedir = get_home_dir()
            path = getexistingdirectory(parent=self,
                                        caption=_("Open project"),
                                        basedir=basedir)
            if not self.is_valid_project(path):
                if path:
                    QMessageBox.critical(self, _('Error'),
                                _("<b>%s</b> is not a Spyder project!") % path)
                return
            else:
                self.add_to_recent(path)

        # A project was not open before
        if self.current_active_project is None:
            if save_previous_files:
                self.editor.save_open_files()
            self.editor.set_option('last_working_dir', getcwd_or_home())
            self.show_explorer()
        else: # we are switching projects
            self.set_project_filenames(self.editor.get_open_filenames())

        self.current_active_project = EmptyProject(path)
        self.latest_project = EmptyProject(path)
        self.set_option('current_project_path', self.get_active_project_path())
        self.setup_menu_actions()
        self.sig_project_loaded.emit(path)
        self.pythonpath_changed.emit()
        if restart_consoles:
            self.restart_consoles()
开发者ID:0xBADCA7,项目名称:spyder,代码行数:35,代码来源:projects.py


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