本文整理匯總了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)