Exemple #1
0
 def addActionsToMenu(self, updatedFiles, menu):
     """
     Queries updatedFiles() and adds corresponding actions to the menu.
     """
     # PDFs
     pdfs = updatedFiles("pdf")
     for pdf in pdfs:
         name = '"{0}"'.format(os.path.basename(pdf))
         a = menu.addAction(KIcon("application-pdf"),
             i18n("Open %1 in external viewer", name))
         a.triggered.connect((lambda pdf: lambda: self.openPDF(pdf))(pdf))
     if pdfs:
         menu.addSeparator()
     # MIDIs
     midis = updatedFiles("mid*")
     for midi in midis:
         name = '"{0}"'.format(os.path.basename(midi))
         a = menu.addAction(KIcon("media-playback-start"), i18n("Play %1", name))
         a.triggered.connect((lambda midi: lambda: self.openMIDI(midi))(midi))
     if not pdfs and not midis:
         a = menu.addAction(
             i18n("(No up-to-date MIDI or PDF files available.)"))
         a.setToolTip(i18n(
             "There are no up-to-date MIDI or PDF files available. "
             "Please run LilyPond to create one or more output files."))
     else:
         addAccelerators(menu.actions())
Exemple #2
0
 def populateLanguageMenu(self, menu):
     menu.clear()
     # determine doc language
     currentLang = ly.parse.documentLanguage(self.doc.text()) or "nederlands"
     for lang in sorted(ly.pitch.pitchInfo.keys()):
         a = menu.addAction(lang.title())
         a.setCheckable(True)
         if lang == currentLang:
             a.setChecked(True)
         a.triggered.connect((lambda lang: lambda: self.changeLanguage(lang))(lang))
     addAccelerators(menu.actions())