Beispiel #1
0
def testUI2():
    #print Parley.dataDirs()
    #print Parley.pluginDirs()
    #return
    forms = Kross.module("forms")
    mydialog = forms.createDialog("MyDialog")
    mydialog.setButtons("Ok|Cancel")
    mydialog.setFaceType("Plain")  #Auto Plain List Tree Tabbed

    print dir(mydialog)
    #for attr in dir(mydialog):
    #print attr, getattr(mydialog,attr)
    mywidget = forms.createWidgetFromUIFile(
        mydialog,
        Parley.pluginDirs()[0] + "./mywidget.ui")
    mydialog.setMainWidget(mywidget)
    mywidget["QTextEdit"].setText("some string")
    #print dir(mywidget["QPushButton"])
    mywidget["QPushButton"].text = "Push me"
    #mywidget.textEdit.setText("soooome string")
    Parley.connect(mywidget["QPushButton"], "pressed()", click)
    #print mywidget
    print dir(mywidget)
    if mydialog.exec_loop():
        if mydialog.result() == "Ok":
            print mywidget["QTextEdit"].text
Beispiel #2
0
def testUI2():
  #print Parley.dataDirs()
  #print Parley.pluginDirs()
  #return
  forms = Kross.module("forms")
  mydialog = forms.createDialog("MyDialog")
  mydialog.setButtons("Ok|Cancel")
  mydialog.setFaceType("Plain") #Auto Plain List Tree Tabbed
  
  print dir(mydialog)
  #for attr in dir(mydialog):
    #print attr, getattr(mydialog,attr)
  mywidget = forms.createWidgetFromUIFile(mydialog, Parley.pluginDirs()[0]+"./mywidget.ui")
  mydialog.setMainWidget(mywidget)
  mywidget["QTextEdit"].setText("some string")
  #print dir(mywidget["QPushButton"])
  mywidget["QPushButton"].text = "Push me"
  #mywidget.textEdit.setText("soooome string")
  Parley.connect(mywidget["QPushButton"],"pressed()",click)
  #print mywidget
  print dir(mywidget)
  if mydialog.exec_loop():
      if mydialog.result() == "Ok":
          print mywidget["QTextEdit"].text
Beispiel #3
0
    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.."

Beispiel #5
0
    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)
Beispiel #6
0
    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.."
Beispiel #7
0

#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)
Beispiel #8
0
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)
Beispiel #9
0
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
Beispiel #10
0
#print Parley.locales()
#print Parley.localeName("en_US")

#doc = Parley.document()
#doc.callFromScriptTest()

#Parley.document.callFromScriptTest()

#doc = Parley.document
#doc.name = "Hi"
#doc.printName()

def translateFromInternet(word,fromLang,toLang):
    print "Translating from Internet!!.."

Parley.connect("translateWord(const QString &,const QString &,const QString &)",translateFromInternet)

print "TEST ACTION"

registerActions()

#print "OPENING DOCUMENT"
##Parley.open('/home/kde-devel/My\ Vocabularies/test.kvtml')

#print "myscript1"
#init()
#Parley.callFromScript()
#Parley.connect("signalTranslateWord(QString)",translate)
#init()

Beispiel #11
0
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
Beispiel #12
0
#doc = Parley.document()
#doc.callFromScriptTest()

#Parley.document.callFromScriptTest()

#doc = Parley.document
#doc.name = "Hi"
#doc.printName()


def translateFromInternet(word, fromLang, toLang):
    print "Translating from Internet!!.."


Parley.connect(
    "translateWord(const QString &,const QString &,const QString &)",
    translateFromInternet)

print "TEST ACTION"

registerActions()

#print "OPENING DOCUMENT"
##Parley.open('/home/kde-devel/My\ Vocabularies/test.kvtml')

#print "myscript1"
#init()
#Parley.callFromScript()
#Parley.connect("signalTranslateWord(QString)",translate)
#init()