Add API for controlling Anki's GUI
This commit is contained in:
parent
178f8417bc
commit
9e6d963b1a
@ -417,6 +417,22 @@ class AnkiBridge:
|
|||||||
return collection.decks.allNames()
|
return collection.decks.allNames()
|
||||||
|
|
||||||
|
|
||||||
|
def launchBrowser(self, query):
|
||||||
|
browser = aqt.dialogs.open("Browser", self.window())
|
||||||
|
browser.activateWindow()
|
||||||
|
if query:
|
||||||
|
query = u'"{}"'.format(query)
|
||||||
|
browser.form.searchEdit.lineEdit().setText(query)
|
||||||
|
browser.onSearch()
|
||||||
|
return browser.model.cards
|
||||||
|
|
||||||
|
|
||||||
|
def launchAddCards(self):
|
||||||
|
addcards = aqt.dialogs.open("AddCards", self.window())
|
||||||
|
addcards.activateWindow()
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# AnkiConnect
|
# AnkiConnect
|
||||||
#
|
#
|
||||||
@ -516,6 +532,13 @@ class AnkiConnect:
|
|||||||
return API_VERSION
|
return API_VERSION
|
||||||
|
|
||||||
|
|
||||||
|
def api_guiSearch(self, query):
|
||||||
|
return self.anki.launchBrowser(query)
|
||||||
|
|
||||||
|
|
||||||
|
def api_guiAdd(self):
|
||||||
|
return self.anki.launchAddCards()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Entry
|
# Entry
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user