+ # try to open the file
+ try:
+ # load the puzzle
+ self.puzzle = cPickle.load (open (file, "rb"))
+ # assert that it is unfrozen otherwise raise frozen grid exception
+ self.puzzle.assert_frozen_grid ()
+
+ # set selected initial row and column to 0
+ self.selected_row = 0
+ self.selected_col = 0
+ self.window.set_title ("GetAClue player - " + file)
+ # load the clues
+ self.load_clues ()
+ # handle unpickling, and file errors
+ except (cPickle.UnpicklingError, IOError, OSError):
+ dlg = gtk.MessageDialog (self.window, gtk.DIALOG_MODAL,
+ gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE,
+ "Invalid file. Cannot be loaded")
+ dlg.run ()
+ dlg.destroy ()
+ # if the puzzle has no words, then it cannot be played obviously
+ except crosswordpuzzle.NoWordsException:
+ self.puzzle = None
+ dlg = gtk.MessageDialog (self.window, gtk.DIALOG_MODAL,
+ gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE,
+ "Word grid has no words. Cannot play")
+ dlg.run ()
+ dlg.destroy ()
+ # if the puzzle is not frozen then it cannot be played
+ except crosswordpuzzle.FrozenGridException:
+ self.puzzle = None
+ dlg = gtk.MessageDialog (self.window, gtk.DIALOG_MODAL,
+ gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE,
+ "Word grid is not finalized/frozen. Cannot play")
+ dlg.run ()
+ dlg.destroy ()