]>
Softwares of Agnibho - life.git/blob - Cell.py
1 # Agnibho's Game of Life - Python implementation of Conway's Game of Life
2 # Copyright (C) 2014 Agnibho Mondal
4 # This file is part of Agnibho's Game of Life
6 # Agnibho's Game of Life is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # Agnibho's Game of Life is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with Agnibho's Game of Life. If not, see <http://www.gnu.org/licenses/>.
28 def __init__(self
, item
, parent
):
31 self
.__parent
.tag_bind(self
.__obj
, '<ButtonPress-1>', self
.toggle
)
43 self
.__state
=self
.__buff
44 if(self
.__state
=="live"):
45 self
.__parent
.itemconfig(self
.__obj
, fill
="green")
46 elif(self
.__state
=="dead"):
47 self
.__parent
.itemconfig(self
.__obj
, fill
="white")
50 def toggle(self
, event
=False):
51 if(self
.__state
=="live"):
54 self
.__original
="dead"
55 self
.__parent
.itemconfig(self
.__obj
, fill
="white")
56 elif(self
.__state
=="dead"):
59 self
.__original
="live"
60 self
.__parent
.itemconfig(self
.__obj
, fill
="green")
63 self
.__parent
.tag_unbind(self
.__obj
, '<ButtonPress-1>')
66 self
.__parent
.tag_bind(self
.__obj
, '<ButtonPress-1>', self
.toggle
)
69 self
.__buff
=self
.__original
75 self
.__original
="dead"