1 # This program is free software: you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation, either version 3 of the License, or
4 # (at your option) any later version.
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
11 # You should have received a copy of the GNU General Public License
12 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14 from random import shuffle
15 from unicodedata import lookup
17 from pygame import mixer
20 letras = {lookup("tibetan letter ka"):("ka", "sound/ka.mp3"),
21 lookup("tibetan letter kha"):("k'a", "sound/kha.mp3"),
22 lookup("tibetan letter ga"):("k_'a", "sound/kh_a.mp3"),
23 lookup("tibetan letter nga"):("nga", "sound/nga.mp3")}
26 def shuffle_dictionary (dictionary):
28 # keys = list(dictionary.keys())
30 keys = dictionary.keys()
34 def generate_question(list_questions):
35 right_answer = list_questions[0]
36 answers = list_questions[0:4]
38 return right_answer, answers
42 mixer.music.load('Example.ogg')
45 #print letras["ka"][0] # letra tibetana (importante poner el print)
46 #letras["ka"][1] # fichero de sonido
49 keys = shuffle_dictionary(letras)
50 right_answer, answers = generate_question(keys)
52 initializeSnack(ventana)
53 ventana.geometry("185x260+100+80")
54 label = Label(ventana, text = right_answer, font=("", 80))
57 play_sound=Button(ventana,width=40,height=30,fg='black',
58 bitmap='snackPlay', command=play_ogg).place(x=5,y=102)
59 option_1 = Button(ventana,width=7,height=3,fg='black',
60 text=letras[answers[0]][0]).place(x=5,y=140)
61 option_2 = Button(ventana,width=7,height=3,fg='black',
62 text=letras[answers[1]][0]).place(x=5,y=200)
63 option_3 = Button(ventana,width=7,height=3,fg='black',
64 text=letras[answers[2]][0]).place(x=95,y=140)
65 option_4 = Button(ventana,width=7,height=3,fg='black',
66 text=letras[answers[3]][0]).place(x=95,y=200)