########## Importer les modules necessaires ##############
from tkinter import *
from tkinter.font import Font
from random import randrange
##########################################################
########## Fonctions ##################################
##########################################################
def rect(i):
Canevas.create_text(500+150*i,500,text=i,fill="red",font=Mapolice)
##########################################################
########## Variables ##################################
##########################################################
Couleur=["black","red","blue"]
#########################################################
########## Interface graphique ##########################
##########################################################
Mafenetre = Tk()
Mafenetre.title("Titre")
Canevas = Canvas(Mafenetre,width=1000,height=1000,bg ='white')
Canevas.pack()
bouton1=Button(Mafenetre, text="1", command=lambda : rect(1))
bouton1.place(x=100,y=200)
bouton2=Button(Mafenetre, text="2", command=lambda : rect(2))
bouton2.place(x=200,y=200)
Mapolice = Font(family='Liberation Serif', size=200) # création d'une police pour l'affichage du texte
###########################################################
########### Receptionnaire d'évènement ####################
###########################################################
###################### FIN ###############################
Mafenetre.mainloop()
Cela permet d'utiliser un paramêtre dans les fonctions Button, bind, ....