Capstone Project: Flash Card App
This project was the biggest struggle by far, primarily because I was not fully proficient with all the packages.
Here are the things I should remember that may come in handy:
Pandas
- when converting list into .csv file, make dataframe first
- can specify file location as parameter of to_csv() function
data = pandas.DataFrame(to_learn)
data.to_csv("data/words_to_learn.csv")
new_random_word()
- no need to use
with
oropen
when there isread_csv()
function - dictionary becomes list when used parameter
orient="records"
data = pandas.read_csv("data/french_words.csv")
to_learn = data.to_dict(orient="records")
tkinter
- can create text within canvas with
canvas.create_text()
- when creating text inside a canvas, keyword argument to change color is
fill
card_title = canvas.create_text(400, 150, fill="black")
- to modify things inside canvas, first store as a variable and then use
itemconfig()
function
canvas.itemconfig(card_title, fill="white")
- use
canvas.after()
function to create timer without usingwhile
loop -
canvas.after(milliseconds, function)
: carries out a certain function after given milliseconds -in order to prevent timer overlap, we can create a variable to store it
def new_random_word():
global flip_timer
canvas.after_cancel(flip_timer)
...
flip_timer = canvas.after(3000, func=flip_card)
...
flip_timer = canvas.after(3000, func=flip_card)
miscellaneous
-
.remove()
function to delete item from list - can access files that are under the same folder without
./
or../
Top comments (0)