| 26 | """ |
| 27 | |
| 28 | def __init__(self, width, height, x, y, game): |
| 29 | super(Cell, self).__init__('') |
| 30 | self.set_size(width, height) |
| 31 | self.x = x |
| 32 | self.y = y |
| 33 | self.has_mine = False |
| 34 | self.state = 0 # unknown - doubt - flag |
| 35 | self.opened = False |
| 36 | self.nearest_mine = 0 # number of mines adjacent with this cell |
| 37 | self.game = game |
| 38 | |
| 39 | self.style['font-weight'] = 'bold' |
| 40 | self.style['text-align'] = 'center' |
| 41 | self.style['background-size'] = 'contain' |
| 42 | if ((x + y) % 2) > 0: |
| 43 | self.style['background-color'] = 'rgb(255,255,255)' |
| 44 | else: |
| 45 | self.style['background-color'] = 'rgb(245,245,240)' |
| 46 | self.oncontextmenu.do(self.on_right_click, js_stop_propagation=True, js_prevent_default=True) |
| 47 | self.onclick.do(self.check_mine) |
| 48 | |
| 49 | def on_right_click(self, widget): |
| 50 | """ Here with right click the change of cell is changed """ |