#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from tkinter import *

# on crée la fenêtre principale
fenetre = Tk()
fenetre.resizable(width=False, height=False)

# on crée un conteneur A
conteneur_A = Frame(fenetre)
conteneur_A.pack()

# on ajoute des widgets à A
Label(conteneur_A, text="Je suis dans A et j'utilise pack()").pack(padx=5, pady=5)
Label(conteneur_A, text="Moi aussi ! dans A et j'utilise pack()").pack(padx=5, pady=5)

# on ajoute aussi un conteneur B dans A
conteneur_B = Frame(conteneur_A)
conteneur_B.pack(padx=5, pady=5)

Button(
    conteneur_A,
    text="Je suis dans A et j'utilise pack()",
    command=fenetre.destroy,
).pack(padx=5, pady=5)

# maintenant, on ajoute des widgets à B
canvas = Canvas(conteneur_B, bg="white", width=300, height=200)
canvas.create_text(150, 100, text="Je suis dans B et j'utilise grid()")
hbar = Scrollbar(conteneur_B, orient=HORIZONTAL)
vbar = Scrollbar(conteneur_B, orient=VERTICAL)

# on décide de les placer avec grid()
canvas.grid(row=0, column=0, sticky=NW+SE)
hbar.grid(row=1, column=0, sticky=EW)
vbar.grid(row=0, column=1, sticky=NS)

# boucle principale programme
fenetre.mainloop()
