Adding an element on specific rows of a grid using Tkinter Adding an element on specific rows of a grid using Tkinter tkinter tkinter

Adding an element on specific rows of a grid using Tkinter


By adjusting the indices in your for loops and specifying the correct row and column arguments in the .grid() method, you will get the alignment you want:

for ligne in range( tailleGrille*2 + 1):    if (ligne % 2) == 0:        #boutons horizontaux        for colonne in range(tailleGrille):            Button(Frame2, bd=1, height=1, width=8).grid(row=ligne, column=2*colonne+1)    else:        #boutons verticaux        for colonne in range(tailleGrille + 1):            Button(Frame2, bd=1, height=5, width=2).grid(row=ligne, column=2*colonne)