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
|
from tkinter import *
root = Tk()
root.title('grid test')
# création des conteneurs principaux
haut_frame = Frame(root, name = 'en_tete', bg='cyan', width=640, height=50)
gauche_frame = Frame(root, name = 'gauche', bg='blue', height=400)
centre_frame = Frame(root, name = 'grille_sudoku', bg='white')
droite_frame = Frame(root, name = 'droite', bg='red')
bas_frame = Frame(root, name = 'pied_de_page', bg='lavender', height=60)
# Disposition des conteneurs principaux
root.grid_rowconfigure(1, weight=1)
root.grid_columnconfigure(0, weight=1)
root.grid_columnconfigure(1, weight=1)
root.grid_columnconfigure(2, weight=1)
haut_frame.grid(row=0, columnspan=3, sticky="nsew")
gauche_frame.grid(row=1, column=0, sticky="nsew")
centre_frame.grid(row=1, column=1, sticky="nsew")
droite_frame.grid(row=1, column=2, sticky="nsew")
bas_frame.grid(row=2, columnspan=3, sticky="nsew")
centre_frame.columnconfigure(0, weight=1)
centre_frame.columnconfigure(1, weight=1)
centre_frame.columnconfigure(2, weight=1)
centre_frame.rowconfigure(0, weight=1)
centre_frame.rowconfigure(1, weight=1)
centre_frame.rowconfigure(2, weight=1)
for j in range(3):
for i in range(3):
Label(centre_frame, name='{}'.format(i), text='Label {} {}'.format(i,j)).grid(row=j, column=i)
root.mainloop()
root.destroy() |
Partager