Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- file_in_use = 'farsi_words'
- def defaultFile(filename):
- file_in_use = filename
- return file_in_use
- bN = Button(f0, text = 'Nouns', command =lambda: defaultFile('farsi_words'))
- bN.pack(side='left')
- bN.bind("<Button-1>",
- bV = Button(f0, text = 'Verbs', command =lambda: defaultFile('farsi_verbs'))
- bV.pack(side='left')
- bA = Button(f0, text = 'Adjectives', command =lambda: defaultFile('farsi_adjectives'))
- bA.pack(side='left')
- bP = Button(f0, text = 'Prepositions', command =lambda: defaultFile('farsi_preps'))
- bP.pack(side='left')
- def commit(file_in_use):
- word = e1.get()
- definition = e2.get()
- appendFile = open(file_in_use, 'a')#was this defined before def?
- appendFile.write('n' + word + ': ' + definition)
- appendFile.close()
- e1.delete(0, 'end')
- e2.delete(0, 'end')
- def review(file_in_use):
- t1.delete('1.0', END)
- readFile = open(file_in_use, 'r')
- size = 0
- splitList = []
- for line in readFile:
- splitWord = line.split(':')
- splitWord = splitWord[0].strip('n ')
- splitList.append(splitWord)
- size += 1
- n = random.randint(0, size - 1)
- t1.insert(INSERT, splitList[n] + 'n')
- readFile.close()
- def answer(file_in_use):
- word = e3.get()
- def1 = t1.get('1.0','end-1c')
- def1 = def1.strip('n')
- readFile = open(file_in_use, 'r')
- for line in readFile:
- splitWord = line.split(': ')
- if def1 == splitWord[0].strip('n'):
- if word == splitWord[1].strip('n'):
- t1.insert(INSERT, 'Good job!')
- else:
- t1.insert(INSERT, 'Not quite! Good try =)')
- readFile.close()
- def hint(file_in_use):
- def1 = t1.get('1.0','2.0')
- def1 = def1.strip('n')
- readFile = open(file_in_use, 'r')
- for line in readFile:
- splitWord = line.split(': ')
- if def1 == splitWord[0].strip('n'):
- hint = splitWord[1]
- hint1 = t1.get('2.0','end-1c')
- lenHint1 = len(hint1)
- if lenHint1 >= len(hint):
- pass
- else:
- t1.insert(INSERT, hint[lenHint1])
- print (hint1)
- readFile.close()
Add Comment
Please, Sign In to add comment