import tkinter as tk
from tkinter import ttk
class SettingsApp(tk.Tk):
def __init__(self):
super().__init__()
# Configuration de la fenêtre principale
self.title("Paramètres de l'application (Démo LabelFrame)")
self.geometry("600x400")
self.configure(bg='#f0f0f0')
# Création du conteneur principal avec remplissage
main_container = ttk.Frame(self, padding="20")
main_container.pack(fill=tk.BOTH, expand=True)
# Création et placement de la section d'informations personnelles
self.create_personal_info_frame(main_container)
# Création et placement de la section des préférences
self.create_preferences_frame(main_container)
# Création et placement des paramètres de notification
self.create_notification_frame(main_container)
def create_personal_info_frame(self, parent: ttk.Frame) -> None:
"""Crée un LabelFrame pour les paramètres d'informations personnelles."""
personal_frame = ttk.LabelFrame(
parent,
text="Informations Personnelles",
padding="10"
)
personal_frame.pack(fill=tk.X, pady=(0, 10))
# Création et placement des éléments du formulaire
ttk.Label(personal_frame, text="Nom :").grid(row=0, column=0, sticky=tk.W, pady=5)
ttk.Entry(personal_frame).grid(row=0, column=1, sticky=tk.EW, padx=(10, 0))
ttk.Label(personal_frame, text="Email :").grid(row=1, column=0, sticky=tk.W, pady=5)
ttk.Entry(personal_frame).grid(row=1, column=1, sticky=tk.EW, padx=(10, 0))
# Configuration des poids des colonnes de la grille
personal_frame.columnconfigure(1, weight=1)
def create_preferences_frame(self, parent: ttk.Frame) -> None:
"""Crée un LabelFrame pour les préférences de l'application."""
pref_frame = ttk.LabelFrame(
parent,
text="Préférences de l'application",
padding="10"
)
pref_frame.pack(fill=tk.X, pady=(0, 10))
# Sélection du thème
ttk.Label(pref_frame, text="Thème :").grid(row=0, column=0, sticky=tk.W, pady=5)
theme_combo = ttk.Combobox(
pref_frame,
values=["Clair", "Sombre", "Système"],
state="readonly"
)
theme_combo.set("Clair")
theme_combo.grid(row=0, column=1, sticky=tk.EW, padx=(10, 0))
# Sélection de la langue
ttk.Label(pref_frame, text="Langue :").grid(row=1, column=0, sticky=tk.W, pady=5)
lang_combo = ttk.Combobox(
pref_frame,
values=["Anglais", "Espagnol", "Français", "Allemand"],
state="readonly"
)
lang_combo.set("Anglais")
lang_combo.grid(row=1, column=1, sticky=tk.EW, padx=(10, 0))
# Configuration des poids des colonnes de la grille
pref_frame.columnconfigure(1, weight=1)
def create_notification_frame(self, parent: ttk.Frame) -> None:
"""Crée un LabelFrame pour les paramètres de notification."""
notif_frame = ttk.LabelFrame(
parent,
text="Paramètres de notification",
padding="10"
)
notif_frame.pack(fill=tk.X)
# Notifications par email
ttk.Checkbutton(
notif_frame,
text="Activer les notifications par email"
).grid(row=0, column=0, sticky=tk.W, pady=2)
# Notifications de bureau
ttk.Checkbutton(
notif_frame,
text="Activer les notifications de bureau"
).grid(row=1, column=0, sticky=tk.W, pady=2)
# Notifications sonores
ttk.Checkbutton(
notif_frame,
text="Activer les notifications sonores"
).grid(row=2, column=0, sticky=tk.W, pady=2)
if __name__ == "__main__":
app = SettingsApp()
app.mainloop()