Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Hidden-Warden committed May 5, 2022
1 parent 969589b commit 7a33878
Show file tree
Hide file tree
Showing 4 changed files with 252 additions and 0 deletions.
10 changes: 10 additions & 0 deletions DataBase.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
TypeOfCard;Original word;Type of word;Traduction;Definition;Example;Other things to know:;(free category needs to be activated in the settings)
1;Hello;noun;Bonjour;...;Hello, how are you today ?;...;...
1;Goodbye;noun;Au revoir;...;...;...
1;Yes;adverb;Oui;...;...;...
1;No;adverb;Non;...;...;...
1;Tingle(s);verb;Picotement(s);To have a feeling as if a lot of sharp points are being put quickly and lightly into your body.;Avoir des sensation de picotement(s);...;...
1;Surrender;verb;Se rendre;To give up fighting because you know you cannot win.;I would rather die than surrender.;...;...
1;Dance;verb;Danse;To move your body in a way that makes you feel like dancing.;Avoir une envie de danser;In 1780 I was dancing with a guy at the [...] it was amazing;...
1;Dance;noun;Danse;To move your body in a way that makes you feel like dancing.;Avoir une envie de danser Avoir une envie de danser;In 1780 I was dancing with a guy at the [...] it was amazing In 1780 I was dancing with a guy;...
1;This;DataBase;Is;Just;An;Example;FREE category activatedddddddddddddddddddddddd
200 changes: 200 additions & 0 deletions MyCards.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
#Version:
#0.1.1
###
import os ### Librairie
import csv ### Docs / Librairie
import random ### Librairie
import webbrowser ### Librairie
import tkinter.font as font
from tkinter import * ### Librairie
from settings import * ### Docs
from language_modules import * ### Docs
###
Language=[] #List (will contain the words)
NumberOfWord=-1 #The number of the word in the list (DataBase.csv)
GitHub="https://github.com/Hidden-Warden/MyCards/blob/main/README.md" #Link to GitHub ;D
###
with open("DataBase.csv", encoding='utf-8', newline='') as csvfile:
BaseDeMots=list(csv.reader(csvfile,delimiter=s_delimiter))
Rappel_CSV_Title=BaseDeMots[0]
Rappel_CSV_Title.pop(0)
print("Rappel_CSV_Title",Rappel_CSV_Title)
BaseDeMots.pop(0) # Delete the first line in BaseDeMots
###
def language(input_language):
##Choice of the language from the settings:
global Language
if True:
if input_language=="FR":
Language=FR
elif input_language=="EN":
Language=EN
return Language
###
def on_click():
# Refresh the window (delete the previous content)
canvas.delete('all')
###
def Randow_Word():
#Random word from the database
global NumberOfWord
if True:
old_NumberOfWord=NumberOfWord
NumberOfWord=random.randint(0,len(BaseDeMots)-1)
if NumberOfWord==old_NumberOfWord:
NumberOfWord=random.randint(0,len(BaseDeMots)-1)
print("NOF",NumberOfWord)
Update(NumberOfWord)
return NumberOfWord
###
def Next():
global NumberOfWord
if True:
NumberOfWord+=1
if NumberOfWord>=len(BaseDeMots):
NumberOfWord=len(BaseDeMots)-1
Update(NumberOfWord)
return NumberOfWord
###
def Back():
global NumberOfWord
if True:
NumberOfWord-=1
if NumberOfWord<0:
NumberOfWord=0
Update(NumberOfWord)
return NumberOfWord

def GitHubLink():
if True:
webbrowser.open(GitHub)
###

root = Tk()
root.title("MyCards")
root.iconbitmap("MyCards.ico")
root.configure(background=s_background_color)
root.attributes('-fullscreen', full_screen)
###
if s_screen_height > 150 and s_screen_width > 100:
root.geometry(str(s_screen_width)+"x"+str(s_screen_height))
else: #Default size
root.geometry("600x500")
###
if reseizeable_windows==True:
root.resizable(True,True)
else:
root.resizable(False,False)
###////###
language(s_language) #Call the language function.

### All the buttons shown in the window ###
btn1 = Button(root, text =Language[2], activebackground=s_button_color_active,bg=s_button_color_unactive,fg=s_button_texte_color,height=s_button_height, width=s_button_width,borderwidth = 0,command =Randow_Word) #Bouton#// Random
btn1.pack(side = 'top')
#
btn2 = Button(root, text =Language[3], activebackground=s_button_color_active,bg=s_button_color_unactive,fg=s_button_texte_color,height=s_button_height, width=s_button_width,borderwidth = 0,command = root.destroy) #Bouton#// Quit
btn2.place(rely=1.0, relx=1.0, x=0, y=0, anchor=SE)
#
btn3 = Button(root, text =Language[1], activebackground=s_button_color_active,bg=s_button_color_unactive,fg=s_button_texte_color,height=s_button_height, width=s_button_width,borderwidth = 0,command =Back) #Bouton#// Back
btn3.pack(side = 'left')
#
btn4 = Button(root, text =Language[0], activebackground=s_button_color_active,bg=s_button_color_unactive,fg=s_button_texte_color,height=s_button_height, width=s_button_width,borderwidth = 0,command =Next) #Bouton#// Next
btn4.pack(side = 'right')
#
btn5 = Button(root, text =Language[6], activebackground=s_button_color_active,bg=s_button_color_unactive,fg=s_button_texte_color,height=s_button_height, width=s_button_width,borderwidth = 0,command =GitHubLink) #Bouton#// About
btn5.pack(side='bottom')

if super_mode==True:
btn6 = Button(root, text =Language[7], activebackground=s_button_color_active,bg=s_button_color_unactive,fg=s_button_texte_color,height=s_button_height, width=s_button_width,borderwidth = 0,command =GitHubLink) #Bouton#// Super Mode
btn6.pack(anchor=W)
### End of the buttons ###

# Font and size of the buttons
f = font.Font(family=s_button_font_family, size=s_button_font_size)
btn1['font'] = f
btn2['font'] = f
btn3['font'] = f
btn4['font'] = f
btn5['font'] = f
if super_mode==True:
btn6['font'] = f
###
canvas= Canvas(root, width=s_screen_width, height=s_screen_height, bg=s_zone_texte,highlightthickness=3, highlightbackground=s_contour_zone_texte)
canvas.pack()

def Update(Numéro):
# Update the window content with the new word
on_click()
if True:
canvas.create_text((s_screen_width/first_colone), (80), text=Rappel_CSV_Title[0],fill="red", font=s_font_family) ##1
canvas.create_text((s_screen_width/first_colone), (160), text=Rappel_CSV_Title[1],fill=s_font_color, font=s_font_family) ##2
canvas.create_text((s_screen_width/first_colone), (240), text=Rappel_CSV_Title[2],fill="green", font=s_font_family) ##3
canvas.create_text((s_screen_width/first_colone), (320), text=Rappel_CSV_Title[3],fill=s_font_color, font=s_font_family) ##4
canvas.create_text((s_screen_width/first_colone), (420), text=Rappel_CSV_Title[4],fill=s_font_color, font=s_font_family) ##5
canvas.create_text((s_screen_width/first_colone), (560), text=Rappel_CSV_Title[5],fill=s_font_color, font=s_font_family) ##6
if data_base_free_category==True: ##Free category
canvas.create_text((s_screen_width/first_colone), (640), text=Rappel_CSV_Title[6],fill=s_font_color, font=s_font_family) ##7
###
canvas.create_text((s_screen_width/scnd_colone), (80), text=BaseDeMots[Numéro][1],fill="red", font=s_font_family) ##1
canvas.create_text((s_screen_width/scnd_colone), (160), text=BaseDeMots[Numéro][2],fill=s_font_color, font=s_font_family) ##2
canvas.create_text((s_screen_width/scnd_colone), (240), text=BaseDeMots[Numéro][3],fill="green", font=s_font_family) ##3
if len(BaseDeMots[Numéro][4])>=45: ##4
N4_1=(BaseDeMots[Numéro][4][:45]) ##4
N4_2=('-'+BaseDeMots[Numéro][4][45:]) ##4
if len(BaseDeMots[Numéro][4])>=90: ##4
N4_1=(BaseDeMots[Numéro][4][:45]) ##4
N4_2=('-'+BaseDeMots[Numéro][4][45:90]) ##4
N4_3=('-'+BaseDeMots[Numéro][4][90:]) ##4
canvas.create_text((s_screen_width/scnd_colone), (320), text=N4_1,fill=s_font_color, font=s_font_family) ##4
canvas.create_text((s_screen_width/scnd_colone), (350), text=N4_2,fill=s_font_color, font=s_font_family) ##4
canvas.create_text((s_screen_width/scnd_colone), (380), text=N4_3,fill=s_font_color, font=s_font_family) ##4
else: ##4
canvas.create_text((s_screen_width/scnd_colone), (320), text=N4_1,fill=s_font_color, font=s_font_family) ##4
canvas.create_text((s_screen_width/scnd_colone), (350), text=N4_2,fill=s_font_color, font=s_font_family) ##4
else: ##4
canvas.create_text((s_screen_width/scnd_colone), (320), text=BaseDeMots[Numéro][4],fill=s_font_color, font=s_font_family) ##4
#################################################################################################################################
if len(BaseDeMots[Numéro][5])>=45: ##5
N5_1=(BaseDeMots[Numéro][5][:45]) ##5
N5_2=('-'+BaseDeMots[Numéro][5][45:]) ##5
if len(BaseDeMots[Numéro][5])>=90: ##5
N5_1=(BaseDeMots[Numéro][5][:45]) ##5
N5_2=('-'+BaseDeMots[Numéro][5][45:90]) ##5
N5_3=('-'+BaseDeMots[Numéro][5][90:]) ##5
canvas.create_text((s_screen_width/scnd_colone), (420), text=N5_1,fill=s_font_color, font=s_font_family) ##5
canvas.create_text((s_screen_width/scnd_colone), (450), text=N5_2,fill=s_font_color, font=s_font_family) ##5
canvas.create_text((s_screen_width/scnd_colone), (480), text=N5_3,fill=s_font_color, font=s_font_family) ##5
else: ##5
canvas.create_text((s_screen_width/scnd_colone), (420), text=N5_1,fill=s_font_color, font=s_font_family) ##5
canvas.create_text((s_screen_width/scnd_colone), (450), text=N5_2,fill=s_font_color, font=s_font_family) ##5
else: ##5
canvas.create_text((s_screen_width/scnd_colone), (420), text=BaseDeMots[Numéro][5],fill=s_font_color, font=s_font_family) ##5
#################################################################################################################################
if len(BaseDeMots[Numéro][6])>=45: ##6
N6_1=(BaseDeMots[Numéro][6][:45]) ##6
N6_2=('-'+BaseDeMots[Numéro][6][45:]) ##6
canvas.create_text((s_screen_width/scnd_colone), (560), text=N6_1,fill=s_font_color, font=s_font_family) ##6
canvas.create_text((s_screen_width/scnd_colone), (590), text=N6_2,fill=s_font_color, font=s_font_family) ##6
else: ##5
canvas.create_text((s_screen_width/scnd_colone), (560), text=BaseDeMots[Numéro][6],fill=s_font_color, font=s_font_family) ##6
#################################################################################################################################
if data_base_free_category==True: ##Free category ##7
if len(BaseDeMots[Numéro][7])>=45: ##7
N7_1=(BaseDeMots[Numéro][7][:45]) ##7
N7_2=('-'+BaseDeMots[Numéro][7][45:]) ##7
canvas.create_text((s_screen_width/scnd_colone), (640), text=N7_1,fill=s_font_color, font=s_font_family) ##7
canvas.create_text((s_screen_width/scnd_colone), (670), text=N7_2,fill=s_font_color, font=s_font_family) ##7
else: ##5
canvas.create_text((s_screen_width/scnd_colone), (640), text=BaseDeMots[Numéro][7],fill=s_font_color, font=s_font_family) ##7
#################################################################################################################################
####End of the function Update####

root.mainloop()



###old features###

#menubar = Menu(root) ##1
#filemenu = Menu(menubar, tearoff=0) ##1
#menubar.add_cascade(label=Language[4], menu=filemenu) ##-Ajoute le bouton principale "Menu" ##1
2 changes: 2 additions & 0 deletions language_modules.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FR=["Suivant","Retour","Mot aléatoire","Quitter","Menu","Paramètres","À propos","Mise à jours CSV"]
EN=["Next","Back","Random word","Quit","Menu","Settings","About","Update CSV"]
40 changes: 40 additions & 0 deletions settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#Global settings
s_language="EN" #Choosable languages: FR(Français), EN(English)
darkmode=False #True(Dark mode), False(Light mode)
full_screen=False #True(Full screen), False(Windowed)
reseizeable_windows=True #True(Resizeable windows), False(Fixed windows)
s_delimiter=";" #Delimiter used in the CSV file (";" / ",")

first_colone=5 #The higher the value, the more to the left
scnd_colone=2.2 #The higher the value, the more to the left

#Window & font settings
s_screen_width=1920
s_screen_height=1080
s_font_family=('Open Sans','20','bold') #font / font size / font style
s_font_color="black" #general color

###Buttons settings###
s_button_color_unactive="#525E70" #Couleur du BOUTON quand non cliqué #Default: #00CEFF CYAN
s_button_color_active="#FFFFFF" #Couleur du BOUTON quand cliqué #Default: #E300FF VIOLET
s_button_texte_color="#FFFFFF" #Couleur du texte BOUTON
s_button_font_size=12 #Taille texte police BOUTON
s_button_font_family='Open Sans' #Type de police BOUTON
s_button_height=2 #Hauteur du bouton
s_button_width=13 #Largeur du bouton

#In test#
data_base_free_category=False #True(Shown), False(Hidden)
super_mode=False #True(Shown), False(Hidden) #Not yet implemented

###
if darkmode==True:
s_background_color="#081b36"
s_text_color="#FFFFFF"
s_zone_texte="#3F4E63"
s_contour_zone_texte="#FFFFFF"
else:
s_background_color="#081b36"
s_text_color="#FFFFFF"
s_zone_texte="#E5E5E5"
s_contour_zone_texte="#FFFFFF"

0 comments on commit 7a33878

Please sign in to comment.