当前位置: 首页>>代码示例>>Python>>正文


Python KMessageBox.sorry方法代码示例

本文整理汇总了Python中PyKDE4.kdeui.KMessageBox.sorry方法的典型用法代码示例。如果您正苦于以下问题:Python KMessageBox.sorry方法的具体用法?Python KMessageBox.sorry怎么用?Python KMessageBox.sorry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyKDE4.kdeui.KMessageBox的用法示例。


在下文中一共展示了KMessageBox.sorry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: pkgChanges

# 需要导入模块: from PyKDE4.kdeui import KMessageBox [as 别名]
# 或者: from PyKDE4.kdeui.KMessageBox import sorry [as 别名]
    def pkgChanges(self, mode):

        if mode == "install":
            items = self.ui.listViewLanguagesInst.selectedItems()
        else:
            items = self.ui.listViewLanguagesUninst.selectedItems()
            
        if len(items) == 1:
            elm = items[0]
            li = self._localeinfo.listviewStrToLangInfoMap[unicode(elm.text())]
            langPkg = li.languagePkgList["languagePack"]
            if langPkg.available:
                if (mode == "install") and (not langPkg.installed):
                    langPkg.doChange = self.ui.checkBoxTr.isChecked()
                elif (mode == "uninstall") and langPkg.installed:
                    langPkg.doChange = True
            try:
                self._cache.tryChangeDetails(li)
                for langPkg in li.languagePkgList.values():
                  langPkg.doChange = False
            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)

        (to_inst, to_rm) = self._cache.getChangesList()
        if len(to_inst) == len(to_rm) == 0:
            return
        # first install
        self.setCursor(Qt.WaitCursor)
        self.setEnabled(False)
        self.run_pkg_manager(to_inst,to_rm)
        self.setCursor(Qt.ArrowCursor)
        self.setEnabled(True)
        
#        kdmscript = "/etc/init.d/kdm"
#        if os.path.exists("/var/run/kdm.pid") and os.path.exists(kdmscript):
#            subprocess.call(["invoke-rc.d","kdm","reload"])

        #self.run_pkg_manager(to_inst, to_rm)

        if self.returncode == 0:
            if (mode == "install"):
                KMessageBox.information( self, _("All selected components have now been installed for %s.  Select them from Country/Region & Language.") % unicode(items[0].text()), _("Language Installed") )
            elif (mode == "uninstall"):
                KMessageBox.information( self, _("Translations and support have now been uninstalled for %s.") % unicode(items[0].text()), _("Language Uninstalled") )
            # Resync the cache to match packageManager changes, then update views
            self._cache.open(None)
            self.updateLanguagesList()
            self.updateSystemDefaultListbox()
            if mode == "install":
                self.checkInstallableComponents()
        else:
            KMessageBox.sorry(self, _("Failed to set system language."), _("Language Not Set"))
            self._cache.clear() # undo all selections
开发者ID:wzssyqa,项目名称:language-selector-im-config,代码行数:61,代码来源:QtLanguageSelector.py

示例2: slotResult

# 需要导入模块: from PyKDE4.kdeui import KMessageBox [as 别名]
# 或者: from PyKDE4.kdeui.KMessageBox import sorry [as 别名]
	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)
开发者ID:BackupTheBerlios,项目名称:kasablanca-svn,代码行数:11,代码来源:session.py

示例3: email

# 需要导入模块: from PyKDE4.kdeui import KMessageBox [as 别名]
# 或者: from PyKDE4.kdeui.KMessageBox import sorry [as 别名]
 def email(self, updatedFiles, warnpreview=False):
     """
     Collects updated files and provides a nice dialog to send them.
     If warnpreview, the user is warned because he/she would send a PDF
     with point-and-click links in it. The PDFs are MUCH larger in that case.
     """
     if os.path.exists(updatedFiles.lyfile):
         EmailDialog(self.mainwin, updatedFiles, warnpreview).exec_()
     else:
         KMessageBox.sorry(self.mainwin,
             i18n("There are no files to send via email."),
             i18n("No files to send"))
开发者ID:Alwnikrotikz,项目名称:lilykde,代码行数:14,代码来源:actions.py

示例4: remove_key_clicked

# 需要导入模块: from PyKDE4.kdeui import KMessageBox [as 别名]
# 或者: from PyKDE4.kdeui.KMessageBox import sorry [as 别名]
 def remove_key_clicked(self):
   """Remove a trusted software vendor key"""
   item = self.userinterface.treeview2.currentItem()
   if item == None:
       return
   key = item.text(0)
   if not self.remove_key(key[:8]):
     title = _("Error removing the key")
     text = _("The key you selected could not be removed. "
              "Please report this as a bug.")
     KMessageBox.sorry(self.userinterface, utf8(text), utf8(title))
   self.show_keys()
开发者ID:tuquito,项目名称:software-properties,代码行数:14,代码来源:SoftwarePropertiesKDE.py

示例5: __kdeWarning

# 需要导入模块: from PyKDE4.kdeui import KMessageBox [as 别名]
# 或者: from PyKDE4.kdeui.KMessageBox import sorry [as 别名]
 def __kdeWarning(parent, title, text, 
                  buttons = QMessageBox.Ok, defaultButton = QMessageBox.NoButton):
     """
     Function to show a modal warning 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:
         KMessageBox.sorry(parent, text, title)
         return buttons
     
     if __nrButtons(buttons) == 2:
         if defaultButton == QMessageBox.NoButton:
             defaultButton = __getLowestFlag(buttons)
         noButton = defaultButton
         noItem = __getGuiItem(noButton)
         yesButton = int(buttons & ~noButton)
         yesItem = __getGuiItem(yesButton)
         res = KMessageBox.warningYesNo(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.warningYesNoCancel(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.")
开发者ID:usc-bbdl,项目名称:R01_HSC_cadaver_system,代码行数:53,代码来源:KQMessageBox.py

示例6: changeLanguage

# 需要导入模块: from PyKDE4.kdeui import KMessageBox [as 别名]
# 或者: from PyKDE4.kdeui.KMessageBox import sorry [as 别名]
    def changeLanguage(self, lang):
        """
        Change the LilyPond pitch name language in our document to lang.
        
        This is a bit hairy because LilyPond has a new syntax for this since 2.14,
        \language "name", while the old \include "name.ly" still is supported as well.
        """
        newSyntax = (self.doc.lilyPondVersion() or lilyPondVersion()) >= (2, 13, 38)
        text, start = self.doc.selectionOrDocument()
        try:
            changes, includeCommandChanged = ly.tools.translate(text, lang, start)
        except ly.QuarterToneAlterationNotAvailable:
            KMessageBox.sorry(
                self.doc.app.mainwin,
                i18n(
                    "Can't perform the requested translation.\n\n"
                    "The music contains quarter-tone alterations, but "
                    'those are not available in the pitch language "%1".',
                    lang,
                ),
            )
            return

        # Apply the changes.
        with self.doc.editContext():
            changes.applyToCursor(EditCursor(self.doc.doc))
            if not start and not includeCommandChanged:
                if newSyntax:
                    self.addLineToTop('\\language "{0}"'.format(lang))
                else:
                    self.addLineToTop('\\include "{0}.ly"'.format(lang))
        if start and not includeCommandChanged:
            KMessageBox.information(
                self.doc.app.mainwin,
                "<p>{0}</p>"
                '<p><tt>\\include "{1}.ly"</tt> {2}</p>'
                '<p><tt>\\language "{1}"</tt> {3}</p>'.format(
                    i18n(
                        "The pitch language of the selected text has been "
                        "updated, but you need to manually add the following "
                        "command to your document:"
                    ),
                    lang,
                    i18n("(for LilyPond below 2.14), or"),
                    i18n("(for LilyPond 2.14 and higher.)"),
                ),
                i18n("Pitch Name Language"),
            )
开发者ID:Alwnikrotikz,项目名称:lilykde,代码行数:50,代码来源:document.py

示例7: add_key_clicked

# 需要导入模块: from PyKDE4.kdeui import KMessageBox [as 别名]
# 或者: from PyKDE4.kdeui.KMessageBox import sorry [as 别名]
 def add_key_clicked(self):
   """Provide a file chooser that allows to add the gnupg of a trusted
      software vendor"""
   home = QDir.homePath()
   if "SUDO_USER" in os.environ:
       home = os.path.expanduser("~%s" % os.environ["SUDO_USER"])
   url = KUrl.fromPath(home)
   filename = KFileDialog.getOpenFileName(url, 'application/pgp-keys', self.userinterface, utf8(_("Import key")))
   if filename:
     if not self.add_key(filename):
       title = _("Error importing selected file")
       text = _("The selected file may not be a GPG key file " \
               "or it might be corrupt.")
       KMessageBox.sorry(self.userinterface,
             utf8(text),
             utf8(title))
     self.show_keys()
开发者ID:tuquito,项目名称:software-properties,代码行数:19,代码来源:SoftwarePropertiesKDE.py

示例8: convertLy

# 需要导入模块: from PyKDE4.kdeui import KMessageBox [as 别名]
# 或者: from PyKDE4.kdeui.KMessageBox import sorry [as 别名]
def convertLy(mainwin):
    """
    Run the current document through convert-ly.
    """
    doc = mainwin.currentDocument()
    text = doc.text()
    docVersion = ly.version.getVersion(text)
    lilyVersion = ly.version.LilyPondInstance(lilyPondCommand()).version()
    
    if not docVersion:
        KMessageBox.sorry(mainwin, i18n(
            "Can't determine the LilyPond version of the current document."
            " Please add a \\version statement with the correct version."))
    elif not lilyVersion:
        KMessageBox.sorry(mainwin, i18n(
            "Can't determine the version of LilyPond. "
            "Please check your LilyPond installation."))
    elif docVersion >= lilyVersion:
        KMessageBox.information(mainwin, i18n(
            "This LilyPond document is already up-to-date."))
    else:
        # Ok, let's run convert-ly.
        # We add the from-version. Only in that case convert-ly wants to
        # read from stdin.
        try:
            out, err = Popen(
                (convertLyCommand(), "-f", str(docVersion), "-"),
                stdin=PIPE, stdout=PIPE, stderr=PIPE
                ).communicate(text.encode('utf8'))
            if out:
                doc.setText("{0}\n\n%{{\n{1}\n%}}\n".format(out.decode('utf8'), err.decode('utf8')))
                KMessageBox.information(mainwin, i18n(
                 "The document has been processed with convert-ly. You'll find "
                 "the messages of convert-ly in a comment block at the end. "
                 "You still may have to edit some parts manually."))
            else:
                msg = "<br><br>" + err.decode('utf8').replace('\n', '<br>')
                KMessageBox.information(mainwin, i18n(
                 "The document has been processed with convert-ly, but "
                 "remained unchanged. This is the message given by "
                 "convert-ly: %1", msg))
        except OSError as e:
            msg = unicode(e)
            KMessageBox.error(mainwin, i18n("Could not start convert-ly: %1", msg))
开发者ID:Alwnikrotikz,项目名称:lilykde,代码行数:46,代码来源:version.py

示例9: on_button_add_cdrom_clicked

# 需要导入模块: from PyKDE4.kdeui import KMessageBox [as 别名]
# 或者: from PyKDE4.kdeui.KMessageBox import sorry [as 别名]
  def on_button_add_cdrom_clicked(self):
    '''Show a dialog that allows to add a repository located on a CDROM
       or DVD'''
    # testing
    #apt_pkg.Config.Set("APT::CDROM::Rename","true")

    saved_entry = apt_pkg.Config.Find("Dir::Etc::sourcelist")
    tmp = tempfile.NamedTemporaryFile()
    apt_pkg.Config.Set("Dir::Etc::sourcelist",tmp.name)
    progress = CdromProgress(self.datadir, self, kapp)
    cdrom = apt_pkg.GetCdrom()
    # if nothing was found just return
    try:
      res = cdrom.Add(progress)
    except SystemError, msg:
      title = _("CD Error")
      text = _("<big><b>Error scanning the CD</b></big>\n\n%s")%msg
      KMessageBox.sorry(self.userinterface, utf8(text), utf8(title))
      return
开发者ID:tuquito,项目名称:software-properties,代码行数:21,代码来源:SoftwarePropertiesKDE.py

示例10: print_

# 需要导入模块: from PyKDE4.kdeui import KMessageBox [as 别名]
# 或者: from PyKDE4.kdeui.KMessageBox import sorry [as 别名]
 def print_(self, updatedFiles):
     """
     Print updated PDF files.
     
     If there are no updated PDF's a warning is displayed.
     If there is one updated PDF, the print dialog is displayed.
     If there is more than one PDF, a dialog is displayed to select the
     files to print.
     """
     pdfs = updatedFiles("pdf")
     if not pdfs:
         KMessageBox.sorry(self.mainwin, i18n(
             "There are no PDF documents to print.\n\n"
             "You probably need to run LilyPond to create or update a "
             "PDF document. If you are creating MIDI files, be sure you "
             "also put a \layout { } section in your score, otherwise "
             "LilyPond will not create a PDF."),
             i18n("No files to print"))
     elif len(pdfs) == 1:
         printPDF(pdfs[0], self.mainwin)
     else:
         PrintSelectDialog(self.mainwin, pdfs).exec_()
开发者ID:Alwnikrotikz,项目名称:lilykde,代码行数:24,代码来源:actions.py

示例11: transpose

# 需要导入模块: from PyKDE4.kdeui import KMessageBox [as 别名]
# 或者: from PyKDE4.kdeui.KMessageBox import sorry [as 别名]
    def transpose(self):
        """
        Transpose all or selected pitches.
        """
        text, start = self.doc.selectionOrDocument()

        # determine the language and key signature
        language, keyPitch = ly.tools.languageAndKey(text)

        # present a dialog
        dlg = self.transposeDialog()
        dlg.setLanguage(language)
        dlg.setInitialPitch(keyPitch)
        if not dlg.exec_():
            return
        transposer = dlg.transposer()
        if not transposer:
            KMessageBox.sorry(
                self.doc.app.mainwin,
                i18n(
                    "Could not understand the entered pitches.\n\n"
                    'Please make sure you use pitch names in the language "%1".',
                    language,
                ),
            )
            return
        try:
            ly.tools.transpose(text, transposer, start).applyToCursor(EditCursor(self.doc.doc))
        except ly.QuarterToneAlterationNotAvailable:
            KMessageBox.sorry(
                self.doc.app.mainwin,
                i18n(
                    "Can't perform the requested transposition.\n\n"
                    "The transposed music would contain quarter-tone alterations "
                    'that are not available in the pitch language "%1".',
                    language,
                ),
            )
开发者ID:Alwnikrotikz,项目名称:lilykde,代码行数:40,代码来源:document.py

示例12: hyphenate

# 需要导入模块: from PyKDE4.kdeui import KMessageBox [as 别名]
# 或者: from PyKDE4.kdeui.KMessageBox import sorry [as 别名]
def hyphenate(text, mainwindow):
    """
    Ask the user which language to use.
    Returns None if the user cancels the dialog or no hyphenation pattern files
    could be found.
    """
    if not hyphdicts:
        KMessageBox.sorry(mainwindow, i18n(
            "Could not find any hyphenation dictionaries.\n\n"
            "Please install a package containing some and/or or configure the "
            "search path to find them in the Frescobaldi settings under "
            "\"Paths.\""))
        return
    
    conf = config("hyphenation")
    lang = conf.readEntry("lastused", "")
    langs = list(sorted(hyphdicts.keys()))
    index = lang in langs and langs.index(lang) or 0
    
    d = KDialog(mainwindow)
    d.setButtons(KDialog.ButtonCode(KDialog.Ok | KDialog.Cancel | KDialog.Help))
    d.setCaption(i18n("Hyphenate Lyrics Text"))
    d.setHelp("lyrics")
    layout = QVBoxLayout()
    d.mainWidget().setLayout(layout)
    layout.addWidget(QLabel(i18n("Please select a language:")))
    listbox = QListWidget()
    layout.addWidget(listbox)
    listbox.addItems(langs)
    listbox.setCurrentRow(index)
    listbox.setFocus()
    if d.exec_():
        lang = langs[listbox.currentRow()]
        conf.writeEntry("lastused", lang)
        conf.sync()
        # get hyphenator
        h = Hyphenator(hyphdicts[lang])
        return ly.rx.lyric_word.sub(lambda m: h.inserted(m.group(), ' -- '), text)
开发者ID:Alwnikrotikz,项目名称:lilykde,代码行数:40,代码来源:hyphen.py

示例13: insertVersion

# 需要导入模块: from PyKDE4.kdeui import KMessageBox [as 别名]
# 或者: from PyKDE4.kdeui.KMessageBox import sorry [as 别名]
def insertVersion(mainwin):
    """
    Insert the current LilyPond version into the current document
    if it does not already have a version command.
    """
    doc = mainwin.currentDocument()
    for token in ly.tokenize.LineColumnTokenizer().tokens(doc.text()):
        if token == "\\version":
            doc.view.setCursorPosition(KTextEditor.Cursor(token.line, token.column))
            KMessageBox.sorry(mainwin,
                i18n("Your document has already a LilyPond version statement."),
                i18n("Version already set"))
            return
    else:
        lilypond = mainwin.sessionManager().lilyPondCommand()
        version = (lilypond and ly.version.LilyPondInstance(lilypond).version()
                            or defaultVersion())
        if version:
            doc.doc.insertLine(0, '\\version "{0}"'.format(version))
        else:
            KMessageBox.sorry(mainwin,
                i18n("Can't determine the version of LilyPond. "
                     "Please check your LilyPond installation."))
开发者ID:Alwnikrotikz,项目名称:lilykde,代码行数:25,代码来源:version.py

示例14: KApplication

# 需要导入模块: from PyKDE4.kdeui import KMessageBox [as 别名]
# 或者: from PyKDE4.kdeui.KMessageBox import sorry [as 别名]
    gettext.bindtextdomain("language-selector", "/usr/share/locale")
    gettext.textdomain("language-selector")

    app = KApplication()

    args = KCmdLineArgs.parsedArgs()

    if args.isSet("mode"):
        whattodo = args.getOption("mode")
        if whattodo in ["install", "uninstall", "select"]:
            pass
        else:
            print whattodo, "is not a valid argument"
            args.usage()
    else:
        print "Please review the usage."
        args.usage()

    if os.getuid() != 0:
        KMessageBox.sorry(None, _("Please run this software with administrative rights."),  _("Not Root User"))
        sys.exit(1)

    lc = QtLanguageSelector("/usr/share/language-selector/")

    lc.show()

    app.exec_()

# kate: space-indent on; indent-width 4; mixedindent off; indent-mode python;
开发者ID:wzssyqa,项目名称:language-selector-im-config,代码行数:31,代码来源:QtLanguageSelector.py

示例15: error

# 需要导入模块: from PyKDE4.kdeui import KMessageBox [as 别名]
# 或者: from PyKDE4.kdeui.KMessageBox import sorry [as 别名]
 def error(self, summary, message):
     if type(PYQT_VERSION) == int:
         QMessageBox.critical(None, summary, message)
     else:
         KMessageBox.sorry(None, message, summary)
开发者ID:HannesMann,项目名称:Smashbuntu,代码行数:7,代码来源:DistUpgradeFetcherKDE.py


注:本文中的PyKDE4.kdeui.KMessageBox.sorry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。