-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
58 lines (45 loc) · 1.52 KB
/
main.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# -*- coding: utf-8 -*-
import urllib
import urllib2
import json
import aqt.editor
import sys
print(sys.path)
sys.path.append(".")
print(sys.path)
# import the main window object (mw) from ankiqt
from aqt import mw, browser, editor
# import the "show info" tool from utils.py
from aqt.utils import showInfo
from anki.utils import stripHTML
# import all of the Qt GUI library
from aqt.qt import *
from aqt.editor import Editor
#more imports
from anki.hooks import addHook, runHook, wrap
from anki.consts import MODEL_STD
# import web_search.py
from web_search import review_entries
from paint_tool import initialize_canvas
#
#Debugging
#import code
# code.interact(local=locals())
def setupSearchBrowserButton(self):
open_button = self._addButton("imagesDialog", lambda self=self: review_entries(),
text=u"img\u0336", tip="ImageDialog (Ctrl+i)", key="Ctrl+i")
def setupDrawingCanvasButton(self):
canvas_button = self._addButton("Canvas", lambda self=self: initialize_canvas(),
text=u"d\u0336", tip="Canvas (Ctrl+d)", key="Ctrl+d")
def gainFocus(note, field):
global search_term
global currentNote
global mediaField
# Sets the search term to the field you're on
# Note: does not work with newly added fields until restart
search_term = note.fields[field]
currentNote = note
mediaField = field
Editor.setupButtons = wrap(Editor.setupButtons, setupSearchBrowserButton)
Editor.setupButtons = wrap(Editor.setupButtons, setupDrawingCanvasButton)
addHook("editFocusGained", gainFocus)