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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
| #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import time
import random
from tkinter import *
import pygame
import pygame.midi
touchenote = {}
octave = 1
x = 1
decalnote = 60
intpourcent = 0
bonne = 0
mauvaise = 0
note = 0
playing = []
def end ():
pygame.quit()
def clic (event):
global note, testdictee, min, max, bonne, mauvaise, intpourcent
X = event.x
Y = event.y
def relache (event):
pass
def silence (event):
pass
def set_piano ():
"affiche les options de piano"
labelmessage.grid_remove()
blackornot.grid_remove()
pourcentmessage.grid_remove()
def set_dictee ():
"affiche les options de dictée"
labelmessage.grid(row=1, column=2, padx=5)
blackornot.grid(row=1, column=3, padx=5)
pourcentmessage.grid(row=1, column=4, padx=5)
fen1 = Tk()
fen1.title("Piano dictée")
radio = StringVar()
radio.set('piano')
message = StringVar()
message.set('message')
black = IntVar()
black.set(0)
pourcent = StringVar()
pourcent.set("100%") # test affichage
canvas = Canvas(fen1, width=758, height=150, bg="white")
canvas.grid(row=0, column=0, columnspan=10, padx=5, pady=5)
canvas.bind('<Button-1>', clic)
canvas.bind('<Button-3>', clic)
canvas.bind('<ButtonRelease-1>', relache)
canvas.bind('<ButtonRelease-2>', silence)
piano = Radiobutton(
fen1, text='piano', variable=radio, value='piano', command=set_piano
)
piano.grid(row=1, column=0, padx=5)
dictee = Radiobutton(
fen1, text='dictée', variable=radio, value='dictee', command=set_dictee
)
dictee.grid(row=1, column=1, padx=5)
labelmessage = Label(fen1, textvariable=message)
blackornot = Checkbutton(fen1, text='noires', variable=black)
pourcentmessage = Label(fen1, textvariable=pourcent)
Button(
fen1, text="Quitter", command=fen1.quit
).grid(row=1, column=9, sticky=E, padx=5, pady=5)
fen1.columnconfigure(9, weight=1)
fen1.mainloop() |
Partager