~foosoft/anki-connect

842dae9830a9a60b097b71c939dd94503ac3503b — Charles Henry 7 years ago 5ec3df7
Prefix gui to GUI related functions and update readme
2 files changed, 22 insertions(+), 19 deletions(-)

M AnkiConnect.py
M README.md
M AnkiConnect.py => AnkiConnect.py +12 -12
@@ 434,7 434,7 @@ class AnkiBridge:
        addCards.activateWindow()


    def getNextCard(self):
    def guiGetNextCard(self):
        if self.window().reviewer.card is None or self.window().state != 'review':
            self.window().moveToState('review')



@@ 452,7 452,7 @@ class AnkiBridge:
        }


    def showQuestion(self):
    def guiShowQuestion(self):
        if self.window().reviewer.card is None or self.window().state != 'review':
            self.window().moveToState('review')



@@ 460,7 460,7 @@ class AnkiBridge:
        return {'success': True}


    def showAnswer(self):
    def guiShowAnswer(self):
        if self.window().reviewer.mw.state != 'review':
            return {'success': False, 'message': 'Window state is not review.'}
        else:


@@ 468,7 468,7 @@ class AnkiBridge:
            return {'success': True}


    def answerCard(self, id, ease):
    def guiAnswerCard(self, id, ease):
        if self.window().reviewer.mw.state != 'review':
            return {'success': False, 'message': 'Window state is not review.'}
        elif self.window().reviewer.state != 'answer':


@@ 597,20 597,20 @@ class AnkiConnect:
        return self.anki.guiAddCards()


    def api_getNextCard(self):
        return self.anki.getNextCard()
    def api_guiGetNextCard(self):
        return self.anki.guiGetNextCard()


    def api_answerCard(self, id, ease):
        return self.anki.answerCard(id, ease)
    def api_guiAnswerCard(self, id, ease):
        return self.anki.guiAnswerCard(id, ease)


    def api_showQuestion(self):
        return self.anki.showQuestion()
    def api_guiShowQuestion(self):
        return self.anki.guiShowQuestion()


    def api_showAnswer(self):
        return self.anki.showAnswer()
    def api_guiShowAnswer(self):
        return self.anki.guiShowAnswer()


    def api_checkState(self):

M README.md => README.md +10 -7
@@ 336,7 336,7 @@ rather than raw JSON. If you are writing raw requests be sure to send valid JSON
    null
    ```

*   **getNextCard**
*   **guiGetNextCard**

    Returns next/current card, calling this multiple times will not skip unanswered cards.



@@ 353,7 353,7 @@ rather than raw JSON. If you are writing raw requests be sure to send valid JSON
    {
        'success': 'true',
        'question': 'Hello',
        '_fmap': {
        'fieldMap': {
            'Front': [
                0,
                {


@@ 393,15 393,18 @@ rather than raw JSON. If you are writing raw requests be sure to send valid JSON
                'Easy'
            ]
        ],
        'model_name': 'Basic',
        'fields': '[\"Hello\", \"Hola\"]',
        'modelName': 'Basic',
        "fields": [
          "Hello",
          "Hola"
        ],
        'answer': 'Hello\n\n<hr id=answer>\n\nHola',
        'ord': 0,
        'id': 1496751176292
    }
    ```

*   **showQuestion**
*   **guiShowQuestion**

    Move Anki to the state of showing a question (window state = 'review' and reviewer state = 'question'). This is required in order to show the answer and can also be used to move from the showAnswer state back to the showQuestion state.



@@ 418,7 421,7 @@ rather than raw JSON. If you are writing raw requests be sure to send valid JSON
    {'success': 'true'}
    ```

*   **showAnswer**
*   **guiShowAnswer**

    Move Anki to the state of showing an answer (window state = 'review' and reviewer state = 'answer'). This is required in order to answer a card.



@@ 440,7 443,7 @@ rather than raw JSON. If you are writing raw requests be sure to send valid JSON
    {'success': 'false', 'message': 'Window state is not review.'}
    ```

*   **answerCard**
*   **guiAnswerCard**

    Used to answer a card that is in the showAnswer state. Valid answers for this card can be found in the getNextCard response.


Do not follow this link