-
Notifications
You must be signed in to change notification settings - Fork 0
/
__init__.py
37 lines (30 loc) · 959 Bytes
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Version announcement plugin for NVDA
# Developer guide example 2
import json
import globalPluginHandler
from scriptHandler import script
from Client import Client
import wx, gui, ui
from Dialog.ChangeWordDialog import ChangeWordDialog
from WordManipulator import Editor
class GlobalPlugin(globalPluginHandler.GlobalPlugin):
@script(gesture="kb:alt+w")
def script_checkWord(self, obj):
editor=Editor()
word = editor.getCurrentWord()
if word is None:
ui.message('There is no text here.')
return
errors = Client.checkWord(word)
if errors is None:
ui.message('There is an error in making request.')
return
if 0 == len(errors):
ui.message('All right.')
return
for words in errors:
self.showDialog(word, words['s'], editor)
def showDialog(self, word, variants, editor):
def onChoose(after):
editor.replaceWord(word, after)
gui.mainFrame._popupSettingsDialog(ChangeWordDialog, words=variants, onChoose=onChoose)