# -*- encoding:utf8 -*-

# Interface graphique incrémentant un compteur: version orientée objet

# Importation du module graphique:

from tkinter import *

# Définition de classe:

class Application(Tk):

    def __init__(self):
        Tk.__init__(self)
        self.title("Exemple")
        # Attribut d'instance à incrémenter:
        self.counter = 0

        # Etiquette de texte:
        self.mes = Label(master = self, text = 'Compteur = 0', fg = 'red')
        self.mes.pack(side = TOP)

        # Boutons:
        bou1 = Button(master = self, text = 'Quitter',
                           command = self.quit)
        bou1.pack(side = RIGHT)
        bou2 = Button(master = self, text = 'Augmenter',
                           command = self.incrementer)
        bou2.pack()

    def incrementer(self):
        self.counter += 1
        self.mes.config(text = 'Compteur = ' + str(self.counter))


#### Corps principal du programme ####

fen = Application()
fen.mainloop()
fen.destroy()

