|
20 | 20 | from remi import start, App |
21 | 21 |
|
22 | 22 |
|
23 | | -class Cell(gui.Widget): |
| 23 | +class Cell(gui.TableItem): |
24 | 24 | """ |
25 | 25 | Represent a cell in the minefield map |
26 | 26 | """ |
27 | 27 |
|
28 | 28 | def __init__(self, width, height, x, y, game): |
29 | | - super(Cell, self).__init__() |
| 29 | + super(Cell, self).__init__('') |
30 | 30 | self.set_size(width, height) |
31 | 31 | self.x = x |
32 | 32 | self.y = y |
@@ -75,7 +75,7 @@ def set_icon(self): |
75 | 75 | self.style['background-image'] = "url('/my_resources:mine.png')" |
76 | 76 | else: |
77 | 77 | if self.nearest_mine > 0: |
78 | | - self.add_child('nearestbomb', "%s" % self.nearest_mine) |
| 78 | + self.set_text(str(self.nearest_mine)) |
79 | 79 | else: |
80 | 80 | self.style['background-color'] = 'rgb(200,255,100)' |
81 | 81 | return |
@@ -167,7 +167,16 @@ def new_game(self, widget): |
167 | 167 | self.mine_table = gui.Table(margin='0px auto')#900, 450 |
168 | 168 | self.mine_matrix = self.build_mine_matrix(8, 8, 5) |
169 | 169 | self.mine_table.empty() |
170 | | - self.mine_table.append_from_list(self.mine_matrix, False) |
| 170 | + |
| 171 | + |
| 172 | + for x in range(0, len(self.mine_matrix[0])): |
| 173 | + row = gui.TableRow() |
| 174 | + for y in range(0, len(self.mine_matrix)): |
| 175 | + row.append(self.mine_matrix[y][x]) |
| 176 | + self.mine_matrix[y][x].onclick.connect(self.mine_matrix[y][x].check_mine) |
| 177 | + self.mine_table.append(row) |
| 178 | + |
| 179 | + #self.mine_table.append_from_list(self.mine_matrix, False) |
171 | 180 | self.main_container.append(self.mine_table, key="mine_table") |
172 | 181 | self.check_if_win() |
173 | 182 | self.set_root_widget(self.main_container) |
|
0 commit comments