def registerActions(): newaction = Parley.newAction("my_script1") print newaction newaction.text="My script 1" Parley.connect(newaction,"triggered()",actionFunction) newaction2 = Parley.newAction("my_script1","My script 2a") Parley.connect(newaction2,"triggered()",actionFunction2) newaction3 = Parley.newAction("my_script1","ui") Parley.connect(newaction3,"triggered()",testUI) newaction4 = Parley.newAction("my_script1","ui2") Parley.connect(newaction4,"triggered()",testUI2) newaction5 = Parley.newAction("my_script1","pyQt") Parley.connect(newaction5,"triggered()",testPyQt) newaction6 = Parley.newAction("my_script1","pyKDE") Parley.connect(newaction6,"triggered()",testPyKDE) return
def registerActions(): newaction = Parley.newAction("my_script1") print newaction newaction.text = "My script 1" Parley.connect(newaction, "triggered()", actionFunction) newaction2 = Parley.newAction("my_script1", "My script 2a") Parley.connect(newaction2, "triggered()", actionFunction2) newaction3 = Parley.newAction("my_script1", "ui") Parley.connect(newaction3, "triggered()", testUI) newaction4 = Parley.newAction("my_script1", "ui2") Parley.connect(newaction4, "triggered()", testUI2) newaction5 = Parley.newAction("my_script1", "pyQt") Parley.connect(newaction5, "triggered()", testPyQt) newaction6 = Parley.newAction("my_script1", "pyKDE") Parley.connect(newaction6, "triggered()", testPyKDE) return
print filename saveas = open(filename, 'w') # remote = wikiObject.download() # workaround: because download method results with http response code 404 content, response_code = fetch_http_content(wikiObject.imageinfo['url'], {}, 'GET') print 'HTTP Response code: ', response_code if (response_code == 200): saveas.write(content) saveas.close() return filename # directory the files are saved to (subdirectory of the document) def getTargetDirectory(): filepath = Parley.doc.url if filepath.startswith('file://'): url = urlparse(filepath) filepath = path.abspath(path.join(url.netloc, url.path)) p, f = path.split(filepath) [name, ext] = f.rsplit(".", 1) filesdir = p + "/" + name + "_files/" return filesdir #create a new action in Parley's script menu action = Parley.newAction("fetch_sound", T.i18n("Fetch Sound")) action.statusTip = T.i18n( "Fetches a sound file from commons.wikimedia.org for the selected word") Parley.connect(action, "triggered()", fetchSound)
assert(f[46] == u"present") c[u"Présent de l'indicatif"] = f[47:53] assert(f[54] == u"imperfect") c[u"Imparfait de l'indicatif"] = f[55:61] assert(f[54] == u"imperfect") c[u"Passé simple de l'indicatif"] = f[63:69] c[u"Futur simple de l'indicatif"] = f[71:77] c[u"Présent du conditionnel"] = f[79:85] return c def testParser(f): print "No parser defined for this language. The conjugation table follows:" for i in xrange(len(f)): print i, f[i] def getConjugationTableParser(lang): if lang == 'es': return spanishParser elif lang == "fr": return frenchParser else: return testParser #create a new action in Parley's script menu action = Parley.newAction("fetch_conjugations","Fetch Conjugations") action.statusTip="Fetches conjugations from en.wiktionary.org" Parley.connect(action,"triggered()",fetchConjugations) print "We got executed.."
if not path.exists(filesdir): os.mkdir(filesdir) filename = filesdir + wikiObject.name.encode('utf-8') print filename saveas = open(filename,'w') # remote = wikiObject.download() # workaround: because download method results with http response code 404 content, response_code = fetch_http_content( wikiObject.imageinfo['url'], {}, 'GET' ) print 'HTTP Response code: ', response_code if(response_code == 200): saveas.write(content) saveas.close() return filename # directory the files are saved to (subdirectory of the document) def getTargetDirectory(): filepath = Parley.doc.url p,f = path.split(filepath) [name,ext] = f.rsplit(".", 1) filesdir = p + "/" + name + "_files/" return filesdir #create a new action in Parley's script menu action = Parley.newAction("fetch_sound",T.i18n("Fetch Sound")) action.statusTip=T.i18n("Fetches a sound file from commons.wikimedia.org for the selected word") Parley.connect(action,"triggered()",fetchSound)
assert (f[54] == u"imperfect") c[u"Imparfait de l'indicatif"] = f[55:61] assert (f[54] == u"imperfect") c[u"Passé simple de l'indicatif"] = f[63:69] c[u"Futur simple de l'indicatif"] = f[71:77] c[u"Présent du conditionnel"] = f[79:85] return c def testParser(f): print "No parser defined for this language. The conjugation table follows:" for i in xrange(len(f)): print i, f[i] def getConjugationTableParser(lang): if lang == 'es': return spanishParser elif lang == "fr": return frenchParser else: return testParser #create a new action in Parley's script menu action = Parley.newAction("fetch_conjugations", "Fetch Conjugations") action.statusTip = "Fetches conjugations from en.wiktionary.org" Parley.connect(action, "triggered()", fetchConjugations) print "We got executed.."
#moves selected entries to a new lesson def moveSelectedToNewLesson(): selected_entries = Parley.selectedEntries() if len(selected_entries) > 0: newlesson = Parley.doc.appendNewLesson(T.i18n("New Lesson")) for entry in selected_entries: newlesson.appendEntry(entry) #marks the selected translations as known (grade 7) def markAsKnown(): for tr in Parley.selectedTranslations(): tr.grade = 7 #SCRIPT MENU #create a new action for the Scripts menu (action1) action1 = Parley.newAction("example_action1", T.i18n("Move to new lesson")) action1.statusTip = T.i18n("Moves the selected vocabulary to a new lesson") Parley.connect(action1, "triggered()", moveSelectedToNewLesson) #create a new action for the Scripts menu (action2) action2 = Parley.newAction("example_action2", T.i18n("Mark as known (highest grade)")) action2.statusTip = T.i18n( "Sets the grade for the selected words to 7 (highest grade)") Parley.connect(action2, "triggered()", markAsKnown)
T = Kross.module("kdetranslation") #FUNCTIONS #moves selected entries to a new lesson def moveSelectedToNewLesson(): selected_entries = Parley.selectedEntries() if len(selected_entries) > 0: newlesson = Parley.doc.appendNewLesson(T.i18n("New Lesson")) for entry in selected_entries: newlesson.appendEntry(entry) #marks the selected translations as known (grade 7) def markAsKnown(): for tr in Parley.selectedTranslations(): tr.grade = 7 #SCRIPT MENU #create a new action for the Scripts menu (action1) action1 = Parley.newAction("example_action1",T.i18n("Move to new lesson")) action1.statusTip=T.i18n("Moves the selected vocabulary to a new lesson") Parley.connect(action1,"triggered()",moveSelectedToNewLesson) #create a new action for the Scripts menu (action2) action2 = Parley.newAction("example_action2",T.i18n("Mark as known (highest grade)")) action2.statusTip=T.i18n("Sets the grade for the selected words to 7 (highest grade)") Parley.connect(action2,"triggered()",markAsKnown)