Exercice2
Améliorer l'affichage de la boite de dialogue de l'exercice précédent (Exercice1) en ajoutant les paramètres width, padx et pady aux boutons:
Solution
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# coding: utf-8 from tkinter import * root = Tk() root.geometry("400x200") root.title("Tkinter Grid Layout") # création des boutons btn1 = Button(root , text = "Button 1" , width = 20) btn2 = Button(root , text = "Button 2" , width = 20) btn3 = Button(root , text = "Button 3" , width = 20) btn4 = Button(root , text = "Button 4" , width = 20) # emplacement des boutons avec la méthod grid() btn1.grid(row = 0 , column = 0 , padx = 10 , pady = 10) btn2.grid(row = 0 , column = 1 , padx = 10 , pady = 10) btn3.grid(row = 1 , column = 0 , padx = 10 , pady = 10) btn4.grid(row = 1 , column = 1 , padx = 10 , pady = 10) root.mainloop() |
Younes Derfoufi
CRMEF OUJDA
1 thought on “Solution Exercice 2: padding - Grid Layout Tkinter”