本文整理汇总了Python中PyKDE4.kdeui.KMessageBox类的典型用法代码示例。如果您正苦于以下问题:Python KMessageBox类的具体用法?Python KMessageBox怎么用?Python KMessageBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KMessageBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: askForPIN
def askForPIN(self):
if "pin" in self.iface.capabilities(self.package)["modes"] and self.iface.requiresPIN(self.package, self.device):
# Loop 3 times by default
for c in range(self.pinDialog.maxTries):
# Clear textbox
self.pinDialog.setPassword("")
if self.pinDialog.exec_():
# Clicked OK
pin = self.pinDialog.password()
# Send PIN to the card, returns True if PIN is valid.
if self.iface.sendPIN(self.package, self.device, str(pin)):
self.pin = str(pin)
self.ui.lineEditPIN.setText(self.pin)
return True
else:
break
# Verification failed for 3 times
if c == self.pinDialog.maxTries-1:
KMessageBox.error(self, i18n("You've typed the wrong PIN code for 3 times"))
return False
else:
# Canceled
return True
else:
# PIN is already entered or the backend doesn't support PIN operations
return True
示例2: file2String
def file2String(self, path):
if(os.path.isfile(path)):
f = open(path, 'r')
return f.read()
else:
KMessageBox.error(None, i18n("No path on this file"), i18n("No path"))
raise RuntimeError("No path")
示例3: unpackError
def unpackError(self, err):
self.progress.setRange(0, 100)
self.progress.reset()
self.enableButtonOk(True)
self.status.setText(i18n("Unpacking failed."))
KMessageBox.error(self, i18n("An error occurred:\n\n%1",
self.unpackJob.errorString()))
示例4: dialogInputBox
def dialogInputBox(message = _("Text"), ontType = "string"):
if (ontType == "date"):
parameters = ["zenity", "--calendar", "--title=" + PROGRAM_NAME, "--text=" + message, "--date-format=%Y-%m-%d"]
else:
parameters = ["kdialog", "--title", PROGRAM_NAME, "--inputbox", message]
try:
dialogProcess = subprocess.Popen(parameters, stdout=subprocess.PIPE)
dialogProcess.wait()
value = u""
for line in iter(dialogProcess.stdout.readline, ''):
value += toUnicode(line)
# Cleaning last "\n".
if (value[-1] == "\n"):
value = value[:-1]
print(toUtf8("dialogInputBox:%s" % value))
except:
value = None
KMessageBox.error(None, "Zenity and KDialog are required to edit resources.")
return value
示例5: __init__
def __init__(self, parent=None):
KStatusNotifierItem.__init__(self, parent)
self.setTitle('synaptiks')
self.setIconByName('synaptiks')
self.setCategory(KStatusNotifierItem.Hardware)
self.setStatus(KStatusNotifierItem.Passive)
self.setup_actions()
self._config = SynaptiksTrayConfiguration(self)
try:
self.touchpad = Touchpad.find_first(Display.from_qt())
except Exception as error:
# show an error message
from synaptiks.kde.error import get_localized_error_message
error_message = get_localized_error_message(error)
options = KMessageBox.Options(KMessageBox.Notify |
KMessageBox.AllowLink)
KMessageBox.error(None, error_message, '', options)
# disable all touchpad related actions
for act in (self.touchpad_on_action, self.preferences_action):
act.setEnabled(False)
# disable synaptiks autostart, the user can still start synaptiks
# manually again, if the reason of the error is fixed
self._config.findItem('Autostart').setProperty(False)
self._config.writeConfig()
else:
self.activateRequested.connect(self.show_configuration_dialog)
# setup the touchpad manager
self.setup_manager(self.touchpad)
示例6: init
def init(self):
self.translateUI()
try:
self.openCache(apt.progress.OpProgress())
except ExceptionPkgCacheBroken:
s = _("Software database is broken")
t = _("It is impossible to install or remove any software. "
"Please use the package manager \"Adept\" or run "
"\"sudo apt-get install -f\" in a terminal to fix "
"this issue at first.")
KMessageBox.error(self, t, s)
sys.exit(1)
self.updateLanguagesList()
self.updateSystemDefaultListbox()
if not self._cache.havePackageLists:
yesText = _("_Update").replace("_", "&")
noText = _("_Remind Me Later").replace("_", "&")
yes = KGuiItem(yesText, "dialog-ok")
no = KGuiItem(noText, "process-stop")
text = "<big><b>%s</b></big>\n\n%s" % (
_("No language information available"),
_("The system does not have information about the "
"available languages yet. Do you want to perform "
"a network update to get them now? "))
text = text.replace("\n", "<br />")
res = KMessageBox.questionYesNo(self, text, "", yes, no)
if res == KMessageBox.Yes:
self.setEnabled(False)
self.update()
self.openCache(apt.progress.OpProgress())
self.updateLanguagesList()
self.setEnabled(True)
示例7: dialogList
def dialogList(parameters = [], message = _("Select")):
value = label = None
try:
if parameters:
parameters = ["kdialog", "--title", PROGRAM_NAME, "--radiolist", message] \
+ parameters
dialogProcess = subprocess.Popen(parameters, stdout=subprocess.PIPE)
dialogProcess.wait()
value = u""
for line in iter(dialogProcess.stdout.readline, ''):
value += toUnicode(line)
# Cleaning last "\n".
if (value[-1] == "\n"):
value = value[:-1]
try:
label = toUnicode(parameters[parameters.index(value) + 1])
except:
label = toUnicode(value)
print(toUtf8("dialogList:%s" % value))
except:
KMessageBox.error(None, "Zenity and KDialog are required to edit resources.")
return value, label
示例8: show_error_dialog
def show_error_dialog(self, message, details=None):
"""
Convenience method for showing an error dialog.
"""
if details is None:
KMessageBox.error(None, message)
else:
KMessageBox.detailedError(None, message, details)
示例9: slotResult
def slotResult(self, job):
print "result"
if job.error():
KMessageBox.sorry(None, job.errorString())
if self.progressWidget.isVisible():
self.progressWidget.hide()
self.frame.setEnabled(True)
示例10: applyChanges
def applyChanges(self):
ui = self.ui
connectionName = unicode(ui.lineConnectionName.text())
try:
self.iface.updateConnection(self.lastEditedPackage, connectionName, self.collectDataFromUI())
except Exception, e:
KMessageBox.error(self.baseWidget, unicode(e))
return
示例11: __kdeAbout
def __kdeAbout(parent, title, text):
"""
Function to show a modal about message box.
@param parent parent widget of the message box
@param title caption of the message box
@param text text to be shown by the message box
"""
KMessageBox.about(parent, text, title)
示例12: show_script_error
def show_script_error(self):
"""
Show the last script error (if any)
"""
if self.service.scriptRunner.error != '':
KMessageBox.information(None, self.service.scriptRunner.error, i18n("View Script Error Details"))
self.service.scriptRunner.error = ''
else:
KMessageBox.information(None, i18n("No error information available"), i18n("View Script Error Details"))
示例13: __call__
def __call__(self):
try:
return self.f()
except _HandledException:
raise
except Exception, e:
txt = "".join(traceback.format_exception(*sys.exc_info()))
KMessageBox.error(None, txt, i18n("Error in action '{}'").format(self.f.__name__))
raise _HandledException(txt)
示例14: handler
def handler(package, exception, args):
if exception:
if self.ui.checkToggler.isChecked():
self.ui.checkToggler.setChecked(False)
else:
self.ui.checkToggler.setChecked(True)
if "Comar.PolicyKit" in exception._dbus_error_name:
KMessageBox.error(self, i18n("Access denied."))
else:
KMessageBox.error(self, unicode(exception))
示例15: deleteBackup
def deleteBackup(self):
global backupInstance
boxresult = KMessageBox.questionYesNo(None, "Really delete backup '" + self.backupList.currentText() + "'?")
if boxresult == KMessageBox.Yes:
resulttype, result = backupInstance.deleteBackup( str(self.backupList.currentText()) )
if result != "ERROR":
KMessageBox.information(None, self.backupList.currentText() + ' deleted.')
self.backupList.removeItem(self.backupList.currentIndex())
else:
KMessageBox.error(None, result[0]['message'])