Commit 4f7867e3 authored by ak's avatar ak
Browse files

add own vocabulary option

parent 6ee49837
......@@ -49,7 +49,8 @@ class Vokabeltrainer():
"[l] Lernen",
"[n] Nachschlagen: " + self.wort,
"[a] Wort hinzufügen",
"[v] Verbessern" ]
"[v] Verbessern",
"[h] Hinzufügen" ]
choice = self.mymenu_preview(choices=choices, prompt="Bitte auswählen")
if choice == 0:
self.uebersetzen()
......@@ -61,12 +62,32 @@ class Vokabeltrainer():
self.add()
elif choice == 4:
self.verbessern()
elif choice == 5:
self.hinzufuegen()
else:
end_menu = True
def verbessern(self):
os.system("vim -c /" + self.wort + " vokabeln/top1000.json")
def hinzufuegen(self):
with open(os.path.join("vokabeln", "top1000.json")) as f:
dictionary = json.loads(f.read())
c = Console()
menuend = False
while not menuend:
print("[bold]Adding vocabulary[/bold]")
self.wort = Prompt.ask("Word")
antwort = Prompt.ask("Translation")
dictionary.update({self.wort: antwort})
if not Confirm.ask("Another word?"):
menuend = True
with open(os.path.join("vokabeln", "top1000.json"), 'w') as f:
f.seek(0)
f.truncate()
json.dump(dictionary, f, indent=2, ensure_ascii=False)
#verbessern()
def mymenu_preview(self, choices=["Exit"], prompt=""):
"""
Ask for user interaction. Show preview function
......
......@@ -999,5 +999,6 @@
"young": "jung",
"your": "",
"yourself": "",
"Mexican": "mexikanisch, der Mexikaner"
"Mexican": "mexikanisch, der Mexikaner",
"": ""
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment