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


Python QMessageBox.critical方法代码示例

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


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

示例1: save_image_as

# 需要导入模块: from AnyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from AnyQt.QtWidgets.QMessageBox import critical [as 别名]
    def save_image_as(self):
        img = self.get_selection().toImage()
        if img.isNull():
            QMessageBox.critical(self, self.tr('Error'), self.tr('No image was selected!'))
            return

        self.hide()

        formats = {
            self.tr('Portable Network Graphics (*.png)'): 'png',
            self.tr('Joint Photographic Experts Group (*.jpg *.jpeg)'): 'jpg',
            self.tr('Graphics Interchange Format (*.gif)'): 'gif',
            self.tr('Bitmap (*.bmp)'): 'bmp',
            self.tr('All Images (*.png *.jpg *.gif *.bmp)'): 'all'
        }

        file_format = None
        destination = QFileDialog.getSaveFileName(self, 'Save image', '', ';;'.join(formats.keys()))
        if isinstance(destination, tuple):
            destination, file_format = destination
            file_format = formats[file_format]
            if file_format == 'all':
                file_format = None

        if not file_format:
            file_format = destination.rsplit('.', 1)[-1]

        if destination:
            if file_format not in formats.values():
                file_format = 'png'
            if not destination.endswith('.' + file_format):
                destination += '.' + file_format
            img.save(destination, file_format, 0 if file_format == 'png' else 90)
        self.reject()
开发者ID:rokups,项目名称:paste2box,代码行数:36,代码来源:screenshot.py

示例2: copy_to_clipboard

# 需要导入模块: from AnyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from AnyQt.QtWidgets.QMessageBox import critical [as 别名]
 def copy_to_clipboard(self):
     img = self.get_selection()
     if img.isNull():
         QMessageBox.critical(self, self.tr('Error'), self.tr('No image was selected!'))
         return
     QApplication.clipboard().setPixmap(img)
     self.reject()
开发者ID:rokups,项目名称:paste2box,代码行数:9,代码来源:screenshot.py

示例3: share_clipboard

# 需要导入模块: from AnyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from AnyQt.QtWidgets.QMessageBox import critical [as 别名]
 def share_clipboard(self):
     mime = QApplication.clipboard().mimeData()
     try:
         wnd = ShareDialog(self, mime=mime)
     except ValueError as e:
         QMessageBox.critical(self, self.tr('Error'), str(e))
         return
     else:
         wnd.show()
         wnd.exec_()
开发者ID:rokups,项目名称:paste2box,代码行数:12,代码来源:gui.py

示例4: save_project

# 需要导入模块: from AnyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from AnyQt.QtWidgets.QMessageBox import critical [as 别名]
    def save_project(self, project_path=None):
        try:
            if project_path is None:
                project_path = QFileDialog.getExistingDirectory(self, "Select the project directory")

            if project_path is not None and str(project_path)!='':
                project_path = str(project_path)
                self.save({}, project_path)
        except Exception as e:
            QMessageBox.critical(self, "Error", str(e))
开发者ID:UmSenhorQualquer,项目名称:pythonVideoAnnotator,代码行数:12,代码来源:base_module.py

示例5: register_hotkeys

# 需要导入模块: from AnyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from AnyQt.QtWidgets.QMessageBox import critical [as 别名]
 def register_hotkeys(self):
     if self._hotkey is not None:
         self.rebuild_menu()
         self._hotkey.unregister(winid=self.winId())
         hotkey_bindings = {
             settings['hotkey/clipboard']: (self.share_clipboard, self._action_clip),
             settings['hotkey/screenshot']: (self.capture_screen, self._action_screen)
         }
         for hotkey, (callback, action) in hotkey_bindings.items():
             if hotkey:
                 if self._hotkey.register(hotkey, callback, self.winId()):
                     sequence = QKeySequence(hotkey) if hotkey else QKeySequence()
                     action.setShortcut(sequence)
                 else:
                     QMessageBox.critical(self, 'Error', 'Could not bind {} hotkey!\n'
                                                         'Key combination {} is probably already in use.'
                                          .format(const.APP_NAME, hotkey))
     else:
         qDebug('Hotkeys are not supported on this platform')
开发者ID:rokups,项目名称:paste2box,代码行数:21,代码来源:gui.py

示例6: save_plot

# 需要导入模块: from AnyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from AnyQt.QtWidgets.QMessageBox import critical [as 别名]
def save_plot(data, file_formats, filename=""):
    _LAST_DIR_KEY = "directories/last_graph_directory"
    _LAST_FILTER_KEY = "directories/last_graph_filter"
    settings = QSettings()
    start_dir = settings.value(_LAST_DIR_KEY, filename)
    if not start_dir or \
            (not os.path.exists(start_dir) and
             not os.path.exists(os.path.split(start_dir)[0])):
        start_dir = os.path.expanduser("~")
    last_filter = settings.value(_LAST_FILTER_KEY, "")
    filename, writer, filter = \
        filedialogs.get_file_name(start_dir, last_filter, file_formats)
    if not filename:
        return
    try:
        writer.write(filename, data)
    except Exception as e:
        QMessageBox.critical(
            None, "Error", 'Error occurred while saving file "{}": {}'.format(filename, e))
    else:
        settings.setValue(_LAST_DIR_KEY, os.path.split(filename)[0])
        settings.setValue(_LAST_FILTER_KEY, filter)
开发者ID:RachitKansal,项目名称:orange3,代码行数:24,代码来源:saveplot.py

示例7: load

# 需要导入模块: from AnyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from AnyQt.QtWidgets.QMessageBox import critical [as 别名]
 def load(self, data, project_path=None):
     try:
         self._project.load(data, project_path)
     except FileNotFoundError as e:
         QMessageBox.critical(self, "Error", str(e))
开发者ID:UmSenhorQualquer,项目名称:pythonVideoAnnotator,代码行数:7,代码来源:base_module.py


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