from tkinter import *
import pandas
import random
# from frames import Timer, Settings: from the folder "frame" import the the two files, timer.py and settings.py
import pygame
pygame.init()
pygame.mixer.music.load("assets/hal.mp3")
def play_hal():
pygame.mixer.music.load("assets/hal.mp3")
pygame.mixer.music.play()
play_hal()
def wild_world():
pygame.mixer.music.load("assets/wildworld.mp3")
pygame.mixer.music.play()
wild_world()
BACKGROUND_COLOR = "#ffffff"
current_card = {}
to_learn = {}
try:
data = pandas.read_csv("data/hebrew.csv")
# data = pandas.read_csv("data/hebrew_words_to_learn.csv")
except FileNotFoundError:
original_data = pandas.read_csv("data/hebrew.csv")
print(original_data)
to_learn = original_data.to_dict(orient="records")
else:
to_learn = data.to_dict(orient="records")
def next_card():
global current_card, flip_timer
window.after_cancel(flip_timer)
current_card = random.choice(to_learn)
canvas.itemconfig(card_title, text="Hebrew", fill="#ffffff")
canvas.itemconfig(card_word, text=current_card["Hebrew"], fill="red")
flip_timer = window.after(12000, func=flip_card)
def flip_card():
data = pandas.read_csv("data/hebrew.csv")
canvas.itemconfig(card_title, text="English", fill="white")
canvas.itemconfig(card_word, text=current_card["English"], fill="blue")
canvas.itemconfig(card_background, image=card_back_img)
def words2Learn():
to_learn.remove(current_card)
print(len(to_learn))
data = pandas.DataFrame(to_learn)
data.to_csv("data/hebrew_words_to_learn.csv", index=False)
next_card()
window = Tk()
window.title("Hebrew Alphabet Learning App")
window.config(padx=50, pady=50, bg=BACKGROUND_COLOR)
flip_timer = window.after(3000, func=flip_card)
canvas = Canvas(width=800, height=550)
bg_image = PhotoImage(file="images/card_front_writing.png")
card_front_img = PhotoImage(file="images/card_front.png")
def cheat_sheet():
canvas.itemconfig(card_background, image=card_front_img)
words2Learn()
play_hal()
card_front_img = PhotoImage(file="images/old_time_alphabet.png")
card_plain_front_img = PhotoImage(file="images/card_front.png")
card_back_img = PhotoImage(file="images/card_back.png")
card_background = canvas.create_image(400, 263, image=card_front_img)
card_title = canvas.create_text(400, 200, text="", font=("helvetica", 30, "bold"))
card_word = canvas.create_text(400, 263, text="", font=("helvetica", 60, "bold"))
canvas.config(bg=BACKGROUND_COLOR, highlightthickness=0)
canvas.grid(row=0, column=0, columnspan=2)
cross_image = PhotoImage(file="images/answers.png")
unknown_button = Button(image=cross_image, highlightthickness=0, text="Answer", command=flip_card)
unknown_button.grid(row=1, column=0)
cheat_sheet_img = PhotoImage(file="images/old_time_thinking.png")
cheat_sheet = Button(image=cheat_sheet_img, highlightthickness=0, text="Answer", command=cheat_sheet)
cheat_sheet.grid(row=0, column=2)
check_image = PhotoImage(file="images/next.png")
known_button = Button(image=check_image, highlightthickness=0, command=next_card)
known_button.grid(row=1, column=1)
next_card()
window.mainloop()