Skip to content

Commit

Permalink
desktop v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
krmanik committed Oct 29, 2020
1 parent e92b630 commit 109aaff
Show file tree
Hide file tree
Showing 11 changed files with 378 additions and 13 deletions.
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@ Create image occlusion in browser.

Anki Image Occlusion app used to create normal, group and combine cloze anki cards for reviewing and studying cards in Anki software (spaced repetition flashcard app, https://apps.ankiweb.net/). The cards generated by this app will be added to AnkiDroid app (Android version of Anki Software). This app is like addon for AnkiDroid. So, before using this app, please make sure you have installed AnkiDroid on your device.

### On desktop, use web version of this app.

https://infinyte7.github.io/image-occlusion-in-browser

Download ```output-all-notes.txt``` and generate deck using this [python script](https://github.com/infinyte7/image-occlusion-in-browser/blob/master/image-occ-deck-export.py).

[Read more](Create-In-Browser.md)<br>
[View demo](demo/combine_cloze_demo_browser.gif)


# App Features
- New design
- Cards auto added to AnkiDroid
Expand Down Expand Up @@ -69,12 +59,24 @@ If not using latest version then following steps to be followed.
- Card will be added one by one. But wait till ```card added``` toast showing on screen.
- Copy svg image from ```Internal Storage/ Android/ data/ io.infinyte7.ankiimageocclusion/ files/``` and original image file to AnkiDroid ```collection.media``` folder.

# Create image occlusion on Desktop
View [Create image occlusion on desktop](desktop/Readme.md)

# Create image occlusion in browser
View [Create image occlusion in browser](Create-In-Browser.md)

# Create image occlusion offline
View [Create image occlusion Offline](Create-Offline.md)

### Using web version of this app.

https://infinyte7.github.io/image-occlusion-in-browser

Download ```output-all-notes.txt``` and generate deck using this [python script](https://github.com/infinyte7/image-occlusion-in-browser/blob/master/image-occ-deck-export.py).

[Read more](Create-In-Browser.md)<br>
[View demo](demo/combine_cloze_demo_browser.gif)

# Build Anki Image Occlusion android app
1. Download this repository
2. Open ```android``` folder in Android Studio
Expand Down
84 changes: 84 additions & 0 deletions desktop/Anki Image Occlusion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
from tkinter import *
from tkinter import font

import os
import time
import random
import subprocess
from glob import glob

from selenium import webdriver
from image_occ_deck_export import exportDeck

class ImageOcclusion:

def __init__(self, master):
self.master = master
master.title("Image Occlusion")

# capture button
fontRoboto = font.Font(family='Roboto', size=16, weight='bold')

btn_capture = Button(master, text="Start", command=self.start)
btn_capture.config(highlightthickness=0, bd=0, fg="white", bg="#5fd38d",
activebackground="#5fd38d", activeforeground="white", font=fontRoboto)
btn_capture.pack(padx="10", pady="10", fill=BOTH)


btn_export = Button(master, text="Export", command=self.export)
btn_export.config(highlightthickness=0, bd=0, fg="white", bg="#5fd38d",
activebackground="#5fd38d", activeforeground="white", font=fontRoboto)
btn_export.pack(padx="10", pady="10", fill=BOTH)

def start(self):
chromedriver = "driver/chromedriver.exe"

# appdata = os.getenv('APPDATA')
appdata = os.getcwd()
download = "Downloads"

if not os.path.exists(download):
os.mkdir(download)

self.anki_dir = appdata + "\\" + download

chromeOptions = webdriver.ChromeOptions()
prefs = {"download.default_directory" : self.anki_dir}
chromeOptions.add_argument("--start-maximized")
chromeOptions.add_experimental_option("prefs", prefs)

self.driver = webdriver.Chrome(executable_path=chromedriver, options=chromeOptions)

self.driver.get("https://infinyte7.github.io/image-occlusion-in-browser/")

# clear download folder
files = glob('Downloads/*')
for f in files:
os.remove(f)


def export(self):
self.driver.execute_script("downloadAllNotes()")

time.sleep(2)
output_file = self.anki_dir + "\\output-all-notes.txt"

ra = random.randrange(1 << 15, 1 << 16)

export = "Export"
if not os.path.exists(export):
os.mkdir(export)

output_deck = export + "/Export-deck-" + str(ra) + ".apkg"
exportDeck(output_file, output_deck)

# clear download folder
files = glob('Downloads/*')
for f in files:
os.remove(f)

window = Tk()
# window.attributes("-topmost", True)
window.geometry("300x140")
my_gui = ImageOcclusion(window)
window.mainloop()
Binary file added desktop/Export/Export-deck-60108.apkg
Binary file not shown.
26 changes: 26 additions & 0 deletions desktop/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# To run this program, install following
1. Python
2. Chrome

# Setup
Install following python module

```
pip install -r requirements.txt
```

# Steps to create Image Occlusion deck
1. Run ```Anki Image Occlusion.py``` file

2. Click ```Start```, it shall open chrome. Wait for page to load.

3. Create image occlusion by importing image and drawing rectangles.

4. Click done button

5. Repeat step 3, 4 and 5, to create more image occlusion

6. Finally, click ```Export``` button to generate decks.

# Demo
![](demo/desktop_demo.gif)
Binary file not shown.
Binary file added desktop/demo/desktop_demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added desktop/driver/chromedriver.exe
Binary file not shown.
Loading

0 comments on commit 109aaff

Please sign in to comment.