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

# Python programozasvizsga - 6TSIb - Juin 2004

from Tkinter import *

class FaceDom:
    def __init__(self, can, val, pos, size =70):
        self.can =can
        # ***
        x, y, c = pos[0], pos[1], size/2
        can.create_rectangle(x -c, y-c, x+c, y+c, fill ='ivory', width =2)
        d = size/3
        # ***
        self.pList =[]
        # ***
        pDispo = [((0,0),), ((-d,d),(d,-d)), ((-d,-d), (0,0), (d,d))]
        disp = pDispo[val -1]
        # ***
        for p in disp:
            self.circle(x +p[0], y +p[1], 5, 'red')
    
    def circle(self, x, y, r, colo):
        # ***
        self.pList.append(self.can.create_oval(x-r, y-r, x+r, y+r, fill=colo))
        
    def erase(self):
        # ***
        for p in self.pList:
            self.can.delete(p)
        
class Project(Frame):
    def __init__(self, width_, height_):
        Frame.__init__(self)
        self.width_, self.height_ = width_, height_
        self.can = Canvas(self, bg='dark green', width =width_, height =height_)
        self.can.pack(padx =5, pady =5)
        # ***
        bList = [("A", self.buttonA), ("B", self.buttonB),
                 ("C", self.buttonC), ("D", self.buttonD),
                 ("Quit", self.buttonQuit)]
        for b in bList:
            Button(self, text =b[0], command =b[1]).pack(side =LEFT)
        self.pack()
    
    def buttonA(self):
        self.d3 = FaceDom(self.can, 3, (100,100), 50)
        
    def buttonB(self):
        self.d2 = FaceDom(self.can, 2, (200,100), 80)
        
    def buttonC(self):
        self.d1 = FaceDom(self.can, 1, (350,100), 110)
        
    def buttonD(self):
        # ***
        self.d3.erase()

    def buttonQuit(self):
        self.master.destroy()
        
Project(500, 300).mainloop()

#taille -> size
#cercle -> circle
#colour -> colo
#effacer -> erase
#larg -> width_
#haut -> height_
#bout -> button