From 9e6d963b1aa33be6ad1aa618359da8a650c7d0e7 Mon Sep 17 00:00:00 2001 From: Glutanimate Date: Sat, 27 May 2017 14:14:40 +0200 Subject: [PATCH] Add API for controlling Anki's GUI --- AnkiConnect.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/AnkiConnect.py b/AnkiConnect.py index 274bc77..e000233 100644 --- a/AnkiConnect.py +++ b/AnkiConnect.py @@ -417,6 +417,22 @@ class AnkiBridge: 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 # @@ -516,6 +532,13 @@ class AnkiConnect: return API_VERSION + def api_guiSearch(self, query): + return self.anki.launchBrowser(query) + + + def api_guiAdd(self): + return self.anki.launchAddCards() + # # Entry #