bonjour
je cherche à dessiner des widgets selon le contexte

j'arrive a la creation et selon l'endroit ou ils se trouvent dans le programme je n'arrive finalement pas a récuperer l'ID

en essayant de les printer j'obtiens : None None None

j'ai bien dans l'idée que frame pourrait me sauver mais je n'ai pas encore compris la nuance

je vous ai livré le code avec le strict minimum
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
import pygame
import time
import pygame.midi
from  tkinter import *
import random
 
 
touchenote= {}
octave = 1
x = 1
decalnote = 60
intpourcent = 0
bonne = 0
mauvaise = 0
note = 0
playing = []
 
testdictee = 0
labelmessage = 0
blackornot = 0
pourcentmessage = 0
 
 
 
def end():
       pygame.quit()
 
 
def Clic (event):
    global note,testdictee,min,max,bonne,mauvaise, intpourcent
    X = event.x
    Y = event.y
 
def piano ():
    global labelmessage,blackornot,pourcentmessage,w
    print ( labelmessage,blackornot,pourcentmessage)
    w.delete(labelmessage)
    w.delete(blackornot)
    w.delete(pourcentmessage)
    fen1.update()
    pass
 
def dictee():
    global labelmessage,blackornot,pourcentmessage,w
    labelmessage = Label (fen1,  textvariable = message).grid(row=2,column=15)
    blackornot = Checkbutton(fen1,text='noires',variable=black).grid(row=2,column=10)
    pourcentmessage = Label (fen1,  textvariable = pourcent).grid(row=2,column=18)
    print (labelmessage,blackornot,pourcentmessage)
    fen1.update()
 
 
def Relache (event):
    pass
 
 
def silence():
    pass
 
fen1 = Tk()
radio = StringVar()
radio.set('piano')
message = StringVar()
message.set('message')
black = IntVar()
black.set(0)
pourcent = StringVar()
message.set('message')
w =Canvas(fen1,width=758,height= 150,bg="white")
w.bind('<Button-1>',Clic)
w.bind('<Button-3>',Clic)
w.bind('<ButtonRelease-1>',Relache)
w.bind('<ButtonRelease-2>',silence)
piano = Radiobutton(fen1, text = 'piano', variable=radio,value = 'piano', command=piano).grid(row=2,column=0)
dictee = Radiobutton(fen1, text = 'dictée', variable=radio,value = 'dictee', command=dictee).grid(row=2,column=4)
fen1.mainloop()
merci pour vos réponses