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
|
##(modules)
from tkinter import *
from random import randrange
####
##(fonctions)
def rndkana():
"permet de choisir aléatoirement l'hiragana ou le katakana"
tplkan = ("B_hir_","B_kat_")
tplsyll = ("a","i","u","e","o","ka","ki","ku","ke","ko","sa","si","su","se","so","ta","ti","tu","te","to","na","ni","nu","ne","no","ma","mi","mu","me","mo","ya","yu","yo","ra","ri","ru","re","ro","wa","wo","n","ha","hi","hu","he","ho")
a = randrange(len(tplkan))
b = randrange(len(tplsyll))
sortie = tplkan[a]+tplsyll[b]
return sortie
def test():
""
#global img
global ar
#img={}
canv1.delete("all")
root = './img/'
fin = rndkana()
path = root+fin+'.gif'
photo = PhotoImage(file=path)
#img['a'] = photo
ar = photo
id = canv1.create_image(100,100,image=photo)
####
##(variables)
root = './img/'
fin = rndkana()
path = root+fin+'.gif'
####
##(interface)
fen = Tk()
canv1 = Canvas(fen, width=200, height=200, bg='white')
canv1.pack()
photo = PhotoImage(file=path)
id = canv1.create_image(100,100,image=photo)
but1 = Button(fen, text="Suivant", command=test)
but1.pack()
fen.mainloop()
#### |
Partager