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

from Tkinter import *
import ttk

# on crée la fenêtre principale
fenetre = Tk()

# on crée un conteneur pour bien présenter
frame = Frame(fenetre)
frame.pack(expand=1, fill=BOTH, padx=2, pady=2)

# on ajoute des widgets
canvas = Canvas(frame, bg="white", width=200, height=150)
canvas.create_text(100, 75, text="Hello good people!")
hbar = ttk.Scrollbar(frame, orient=HORIZONTAL)
vbar = ttk.Scrollbar(frame, orient=VERTICAL)

# on ajoute une petite poignée de redimensionnement
# histoire de faire joli
sizegrip = ttk.Sizegrip(frame)

# on connecte les scrollbars au canevas
canvas.configure(
    xscrollcommand=hbar.set,
    yscrollcommand=vbar.set,
    scrollregion=(0, 0, 800, 600),
)
hbar.configure(command=canvas.xview)
vbar.configure(command=canvas.yview)

# on place les widgets 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)
sizegrip.grid(row=1, column=1)

# on rend le canevas redimensionnable
frame.rowconfigure(0, weight=1)
frame.columnconfigure(0, weight=1)

# on lance la boucle principale
fenetre.mainloop()
