def __kdeQuestion(parent, title, text, buttons = QMessageBox.Ok, defaultButton = QMessageBox.NoButton): """ Function to show a modal critical 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 @param buttons flags indicating which buttons to show (QMessageBox.StandardButtons) @param defaultButton flag indicating the default button (QMessageBox.StandardButton) @return button pressed by the user (QMessageBox.StandardButton) """ if __nrButtons(buttons) == 1: if defaultButton == QMessageBox.NoButton: defaultButton = __getLowestFlag(buttons) yesButton = defaultButton yesItem = __getGuiItem(yesButton) KMessageBox.questionYesNo(parent, text, title, yesItem, KGuiItem()) return yesButton if __nrButtons(buttons) == 2: if defaultButton == QMessageBox.NoButton: defaultButton = __getLowestFlag(buttons) yesButton = defaultButton yesItem = __getGuiItem(yesButton) noButton = int(buttons & ~yesButton) noItem = __getGuiItem(noButton) res = KMessageBox.questionYesNo(parent, text, title, yesItem, noItem) if res == KMessageBox.Yes: return yesButton else: return noButton if __nrButtons(buttons) == 3: if defaultButton == QMessageBox.NoButton: defaultButton = __getLowestFlag(buttons) yesButton = defaultButton yesItem = __getGuiItem(yesButton) buttons = buttons & ~yesButton noButton = __getLowestFlag(buttons) noItem = __getGuiItem(noButton) cancelButton = int(buttons & ~noButton) cancelItem = __getGuiItem(cancelButton) res = KMessageBox.questionYesNoCancel(parent, text, title, yesItem, noItem, cancelItem) if res == KMessageBox.Yes: return yesButton elif res == KMessageBox.No: return noButton else: return cancelButton raise RuntimeError("More than three buttons are not supported.")
def deleteConnection(self): profile = self.sender().parent().profile package = self.sender().parent().package if KMessageBox.questionYesNo( self, i18n("Do you really want to remove profile %1?", profile), "Network-Manager") == KMessageBox.Yes: self.iface.deleteConnection(package, profile)
def mediaChange(self, medium, drive): msg = _("Please insert '%s' into the drive '%s'") % (medium,drive) #change = QMessageBox.question(None, _("Media Change"), msg, QMessageBox.Ok, QMessageBox.Cancel) change = KMessageBox.questionYesNo(None, _("Media Change"), _("Media Change") + "<br>" + msg, KStandardGuiItem.ok(), KStandardGuiItem.cancel()) if change == KMessageBox.Yes: return True return False
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)
def verifyInstalledLangPacks(self): """ called at the start to inform about possible missing langpacks (e.g. gnome/kde langpack transition) """ print "verifyInstalledLangPacks" missing = self.getMissingLangPacks() print "Missing: %s " % missing if len(missing) > 0: # FIXME: add "details" yesText = _("_Install").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" % ( _("The language support is not installed completely"), _("Some translations or writing aids available for your " "chosen languages are not installed yet. Do you want " "to install them now?")) text = text.replace("\n", "<br />") res = KMessageBox.questionYesNo(self, text, "", yes, no) if res == KMessageBox.Yes: self.setEnabled(False) self.commit(missing, []) self.updateLanguagesList() self.setEnabled(True)
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'])
def mediaChange(self, medium, drive): msg = _("Please insert '%s' into the drive '%s'") % (medium, drive) #change = QMessageBox.question(None, _("Media Change"), msg, QMessageBox.Ok, QMessageBox.Cancel) change = KMessageBox.questionYesNo(None, _("Media Change"), _("Media Change") + "<br>" + msg, KStandardGuiItem.ok(), KStandardGuiItem.cancel()) if change == KMessageBox.Yes: return True return False
def deleteConnection(self): profile = self.sender().parent().profile package = self.sender().parent().package if ( KMessageBox.questionYesNo( self, i18n("Do you really want to remove profile %1?", profile), "Network-Manager" ) == KMessageBox.Yes ): self.iface.deleteConnection(package, profile)
#!/usr/bin/env python import sys from PyQt4.QtCore import QString from PyKDE4.kdecore import ki18n, KAboutData, KCmdLineArgs from PyKDE4.kdeui import KApplication, KGuiItem, KMessageBox appName = "helloworld" catalog = "" programName = ki18n("helloworld") version = "1.0" description = ki18n("Tutorial - First Program") license = KAboutData.License_GPL copyright = ki18n("(c) 2007 Jim Bublitz") text = ki18n("none") homePage = "www.riverbankcomputing.com" bugEmail = "*****@*****.**" aboutData = KAboutData( appName, catalog, programName, version, description, license, copyright, text, homePage, bugEmail ) KCmdLineArgs.init(sys.argv, aboutData) app = KApplication() guiItem = KGuiItem(QString("Hello"), QString(), QString("this is a tooltip"), QString("this is a whatsthis")) KMessageBox.questionYesNo(None, "Hello World", "Hello", guiItem)
def confirmQuit(self): result = KMessageBox.questionYesNo(None, "Really quit?") if result == KMessageBox.Yes: app.quit()
#!/usr/bin/env python import sys from PyQt4.QtCore import QString from PyKDE4.kdecore import ki18n, KAboutData, KCmdLineArgs from PyKDE4.kdeui import KApplication, KGuiItem, KMessageBox appName = "helloworld" catalog = "" programName = ki18n("helloworld") version = "1.0" description = ki18n("Tutorial - First Program") license = KAboutData.License_GPL copyright = ki18n("(c) 2007 Jim Bublitz") text = ki18n("none") homePage = "www.riverbankcomputing.com" bugEmail = "*****@*****.**" aboutData = KAboutData(appName, catalog, programName, version, description, license, copyright, text, homePage, bugEmail) KCmdLineArgs.init(sys.argv, aboutData) app = KApplication() guiItem = KGuiItem(QString("Hello"), QString(), QString("this is a tooltip"), QString("this is a whatsthis")) KMessageBox.questionYesNo(None, "Hello World", "Hello", guiItem)