+ # callback for menu item hide solution activated event
+ def on_hidesolution_activate (self, menuitem):
+ if self.puzzle:
+ # hide the solution
+ self.puzzle.reveal_solution (False)
+ puzgrid = self.ui.get_object ("puzzlegrid")
+ # redraw the grid
+ puzgrid.queue_draw ()
+
+ # callback for menu item reveal solution activated event
+ def on_revealsolution_activate (self, menuitem):
+ if self.puzzle:
+ # confirm first
+ dlg = gtk.MessageDialog (self.window, gtk.DIALOG_MODAL,
+ gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO,
+ "This will reveal all words in the puzzle! Are you sure?")
+ if dlg.run () == gtk.RESPONSE_YES:
+ # reveal the solution
+ self.puzzle.reveal_solution ()
+ # redraw the grid
+ puzgrid = self.ui.get_object ("puzzlegrid")
+ puzgrid.queue_draw ()
+ dlg.destroy ()
+
+ # callback for menu item reveal word activated event
+ def on_revealword_activate (self, menuitem):
+ if self.puzzle:
+ # reveal across/down word if any the position
+ if self.puzzle.data[self.selected_row][self.selected_col].occupied_across is True:
+ dlg = gtk.MessageDialog (self.window, gtk.DIALOG_MODAL,
+ gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO,
+ "Are you sure you wish to reveal across word at current cell?")
+ # confirm that the user wants to reveal
+ if dlg.run () == gtk.RESPONSE_YES:
+ self.puzzle.reveal_word_across (self.selected_row, self.selected_col)
+ # redraw the grid to reveal the word
+ puzgrid = self.ui.get_object ("puzzlegrid")
+ puzgrid.queue_draw ()
+ dlg.destroy ()
+ if self.puzzle.data[self.selected_row][self.selected_col].occupied_down is True:
+ dlg = gtk.MessageDialog (self.window, gtk.DIALOG_MODAL,
+ gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO,
+ "Are you sure wish to reveal down word at current cell?")
+ if dlg.run () == gtk.RESPONSE_YES:
+ self.puzzle.reveal_word_down (self.selected_row, self.selected_col)
+ # redraw the grid to reveal the word
+ puzgrid = self.ui.get_object ("puzzlegrid")
+ puzgrid.queue_draw ()
+ dlg.destroy ()
+
+