@@ -101,10 +101,10 @@ def __init__(self, master):
101101
102102 #add mine and count at the end
103103 self .label2 = Label (frame , text = "Mines: " + str (self .mines ))
104- self .label2 .grid (row = 11 , column = 0 , columnspan = 5 )
104+ self .label2 .grid (row = SIZE_X + 1 , column = 0 , columnspan = SIZE_Y / 2 )
105105
106106 self .label3 = Label (frame , text = "Flags: " + str (self .flags ))
107- self .label3 .grid (row = 11 , column = 4 , columnspan = 5 )
107+ self .label3 .grid (row = SIZE_X + 1 , column = SIZE_Y / 2 - 1 , columnspan = SIZE_Y / 2 )
108108
109109 ## End of __init__
110110
@@ -153,7 +153,7 @@ def rclicked(self, button_data):
153153 elif button_data ["state" ] == 2 :
154154 button_data ["widget" ].config (image = self .tiles ["plain" ])
155155 button_data ["state" ] = 0
156- button_data ["widget" ].bind (BTN_CLICK , self .lclicked_wrapper (button_data ["coords" ][x ], button_data ["coords" ][y ]))
156+ button_data ["widget" ].bind (BTN_CLICK , self .lclicked_wrapper (button_data ["coords" ]["x" ], button_data ["coords" ]["y" ]))
157157 # if a mine
158158 if button_data ["isMine" ] == True :
159159 self .correct_flags -= 1
@@ -191,7 +191,7 @@ def clear_empty_tiles(self, id):
191191 self .check_tile (source_x + 1 , source_y , queue ) #bottom middle
192192 self .check_tile (source_x + 1 , source_y + 1 , queue ) #bottom left
193193
194- def gameover (self ):
194+ def reveal (self ):
195195 for x in range (0 , SIZE_X ):
196196 for y in range (0 , SIZE_Y ):
197197 if self .buttons [x ][y ]["isMine" ] == False and self .buttons [x ][y ]["state" ] == STATE_FLAGGED :
@@ -200,12 +200,15 @@ def gameover(self):
200200 self .buttons [x ][y ]["widget" ].config (image = self .tiles ["mine" ])
201201 global root
202202 root .update ()
203+
204+ def gameover (self ):
205+ self .reveal ()
203206 tkMessageBox .showinfo ("Game Over" , "You Lose!" )
207+ global root
204208 root .destroy ()
205209
206210 def victory (self ):
207- global root
208- root .update ()
211+ self .reveal ()
209212 tkMessageBox .showinfo ("Game Over" , "You Win!" )
210213 root .destroy ()
211214
0 commit comments