本文整理汇总了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()
示例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()
示例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_()
示例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))
示例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')
示例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)
示例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))