本文整理汇总了Python中winpython.qt.QtGui.QMessageBox.critical方法的典型用法代码示例。如果您正苦于以下问题:Python QMessageBox.critical方法的具体用法?Python QMessageBox.critical怎么用?Python QMessageBox.critical使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类winpython.qt.QtGui.QMessageBox
的用法示例。
在下文中一共展示了QMessageBox.critical方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_packages
# 需要导入模块: from winpython.qt.QtGui import QMessageBox [as 别名]
# 或者: from winpython.qt.QtGui.QMessageBox import critical [as 别名]
def process_packages(self, action):
"""Install/uninstall packages"""
if action == "install":
text, table = "Installing", self.table
if not self.get_packages_to_be_installed():
return
elif action == "uninstall":
text, table = "Uninstalling", self.untable
else:
raise AssertionError
packages = table.get_selected_packages()
if not packages:
return
func = getattr(self.distribution, action)
thread = Thread(self)
for widget in self.children():
if isinstance(widget, QWidget):
widget.setEnabled(False)
try:
status = self.statusBar()
except AttributeError:
status = self.parent().statusBar()
progress = QProgressDialog(self, Qt.FramelessWindowHint)
progress.setMaximum(len(packages)) # old vicious bug:len(packages)-1
for index, package in enumerate(packages):
progress.setValue(index)
progress.setLabelText("%s %s %s..." % (text, package.name, package.version))
QApplication.processEvents()
if progress.wasCanceled():
break
if package in table.model.actions:
try:
thread.callback = lambda: func(package)
thread.start()
while thread.isRunning():
QApplication.processEvents()
if progress.wasCanceled():
status.setEnabled(True)
status.showMessage("Cancelling operation...")
table.remove_package(package)
error = thread.error
except Exception as error:
error = to_text_string(error)
if error is not None:
pstr = package.name + " " + package.version
QMessageBox.critical(
self,
"Error",
"<b>Unable to %s <i>%s</i></b>" "<br><br>Error message:<br>%s" % (action, pstr, error),
)
progress.setValue(progress.maximum())
status.clearMessage()
for widget in self.children():
if isinstance(widget, QWidget):
widget.setEnabled(True)
thread = None
for table in (self.table, self.untable):
table.refresh_distribution(self.distribution)