Exercice 6
Reprendre l'exercice précédent (Exercice 5) en utilisant la méthode StringVar() et le paramètre textvaraible associé au label.
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 * def validate(): var.set("Hello World !") root = Tk() root.geometry("400x200") root.title("Message Hello ") # utilisation de la méthode StringVar() var = StringVar() # Label qui affiche le résultat lblResult = Label(root , textvariable = var) lblResult.place(x = 100 , y = 50) btnValidate = Button(root , text = "Validate" , command = validate) btnValidate.place(x = 100 , y = 80 , width = 200) root.mainloop() |
Younes Derfoufi
CRMEF OUJDA

![[App intégrée] 2025 Upgraded Vidéoprojecteur 1920 * 1080P FHD 4K Mini Projecteur Portable Dual Contrôle avec Souris Android TV WiFi 6 BT5.2 180° Rotation Compatible avec HDMI/TV Stick/USB](https://www.tresfacile.net/wp-content/uploads/2025/12/Videoprojecteur-1920-1080P-FHD-4K-Mini-Projecteur-Portable-Dual-Control-250x236.png)

1 thought on “Solution Exercice 6: methode StringVar associé au label tkinter”