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
|
# fenêtre simpliste
from tkinter import *
def can_create():
can1 = Canvas(fen1,bg='dark grey',height=200,width=200)
can1.pack(side=RIGHT)
# Création du widget principal ("maître") :
fen1 = Tk()
# création des widgets "esclaves" :
tex1 = Label(fen1, text='Bonjour tout le monde !', fg='red')
tex1.pack()
can1 = Canvas(fen1,bg='dark grey',height=200,width=200)
can1.pack(side=RIGHT)
bou1 = Button(fen1, text='Canevas Destroy', command = can1.destroy)
bou1.pack()
bou2 = Button(fen1, text='Quitter', command = fen1.destroy)
bou2.pack(side=BOTTOM)
bou3 = Button(fen1, text='Canevas Create', command = can_create)
bou3.pack(side=LEFT)
# démarrage du réceptionnaire d'événements
fen1.mainloop()
# On met le programme en pause pour éviter qu'il ne se referme (Windows)
os.system("pause") |
Partager