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
| from tkinter import *
#Définition du corps
def corps ():
#Définition du canvas de fond
Thanatos = Canvas(fenetre, height = 50, width = 50, bg="#DDDDDD").grid()
#Définition du canvas bougeant
cnv = Canvas(fenetre, width = 700, highlightbackground = "#666666")
cnv.config(highlightthickness=1)
cnv.grid(row=0, column=0, sticky='ns')
#les scrolls
hScroll = Scrollbar(Thanatos, orient=HORIZONTAL, command=cnv.xview)
hScroll.grid(row=1, column=0, sticky='we')
vScroll = Scrollbar(Thanatos, orient=VERTICAL, command=cnv.yview)
vScroll.grid(row=0, column=1, sticky='ns')
cnv.configure(xscrollcommand=hScroll.set, yscrollcommand=vScroll.set)
#Définition de la Frame contenant les objets
frm = Frame(cnv, highlightbackground = "green")
frm.config(highlightthickness=1)
#Création de canvas
for i in range(50):
for j in range(50):
Canvas(frm, height = 20, width = 20, highlightbackground = "red", highlightthickness=1).grid(row = i, column = j)
frm.update()
cnv.create_window(0, 0, window=frm, anchor=NW)
cnv.configure(scrollregion=cnv.bbox(ALL))
fenetre = Tk()
corps()
mainloop() |
Partager