-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflashCard.py
71 lines (59 loc) · 2.35 KB
/
flashCard.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
59
60
61
62
63
64
65
66
67
68
69
70
import os
import random as rand
from card import *
from deck import *
from deckHandler import *
# TODO make cards with math formulas / latex
# TODO make cards use images, os.command('imshow X')
# when creating card, just give it image filepath
# TODO pretty print the card in a box with status displayed
###############§ Utility
def copyFile(fname):
global deckPath
copy = open(deckPath + fname + '_copy','w')
inf = open(fname,'r')
if copy.write(inf.read()) > 0:
return True
return False
def printMainMenu():
print('-------------------------------------------------------------------')
print('load or create new deck: l <deck name>')
print('quit: q')
print('-------------------------------------------------------------------')
def printDeckMenu(deckName):
print('-------------------------------------------------------------------')
print('Deck: ',deckName.upper()) # maybe make a fun ascii title print
print('add card: a <front> <CR> <back>')
print('next card: n, (type n again to flip)')
print('master card : m')
print('quit to main menu: q')
#print('\t note: promotes card status until card mastered') # should appear in help menu
print('-------------------------------------------------------------------')
def printCardMenu():
print('--------------------')
print('m - master')
print('n - next')
print('--------------------')
###############§ Main
def mainLoop(deckNames):
usrInput = ''
dealer = deckHandler(deckNames)
while usrInput != 'q':
printMainMenu()
usrInput = input('§ ')
if len(usrInput) == 0:
continue
action = usrInput[0]
if action == 'l': # load deck or new deck
deckName = usrInput[2:]
deckName = deckName.lower()
dealer.openDeck(deckName) # add these params (deckNames,deckNames) when you want to check for preexisting deck
dealer.deckLoop() # run() maybe should spawn a thread, that way you could error handle instead of main application crashing?
print('Ciao')
###############§ Globals
deckPath = './Decks/' # TODO redfine path during installation
if __name__ == '__main__':
# load deck names, compare to determine if new deck or preexisting deck
deckNames = [d.lower() for d in os.listdir(deckPath)]
print(deckNames)
mainLoop(deckNames)