-
Notifications
You must be signed in to change notification settings - Fork 0
/
Flashcards.pyw
80 lines (68 loc) · 2 KB
/
Flashcards.pyw
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
71
72
73
74
75
76
77
78
79
80
import csv
import tkinter as tk
from tkinter import *
from random import randint, seed
#make sure that theres the spanish word first in the csv file
file = open('words.csv')
type(file)
csvreader = csv.reader(file)
rows = []
for row in csvreader:
rows.append(row)
max = 0
for row in rows:
max=max+1
max=max-1
def getNewRow():
newrow = randint(0, max)
trow = rows[newrow]
return trow
def refresh():
global root
global cw
global check_button
canvas.delete('all')
canvas.create_text(x, y-25, text=cw[0], fill="White", font=('Arial 30'))
check_button.configure(command=next)
def next():
global root
global cw
global check_button
canvas.delete('all')
canvas.create_text(x, y-25, text=cw[1], fill="White", font=('Arial 30'))
check_button.configure(command=refresh)
def newword():
global cw
save=cw
cw=getNewRow()
while save==cw:
cw=getNewRow()
canvas.delete('all')
canvas.create_text(x, y-25, text=cw[0], fill="White", font=('Arial 30'))
check_button.configure(command=next)
root=tk.Tk()
global cw
cw=getNewRow()
global canvas
global check_button
root.resizable(False, False)
root.attributes('-topmost', 'false')
root.configure(bg="Navy")
root.title("Flashcards")
width = 600
height = 500
next_button = Button(root, text="Next",font="Arial 15 bold", command=newword, width=round(width/2), bg="#3EB489", activebackground="#3EB489")
next_button.pack(pady=5, side=BOTTOM)
check_button = Button(root, text="Flip",font="Arial 15 bold", command=refresh, width=round(width/2), bg="#3EB489", activebackground="#3EB489")
check_button.pack(pady=5, side=BOTTOM)
canvas= Canvas(root, width= width, height= height, bg="Navy",highlightthickness=0)
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
posX = round((screen_width/2) - (width/2))
posY = round((screen_height/2) - (height/2))
x=round(width/2)
y=round(height/2)
newword()
canvas.pack()
root.geometry(f'{width}x{height}+{posX}+{posY}')
root.mainloop()