+ try:
+ aword, arow, acol, alen = self.puzzle.get_word_across (row, col)
+ sys.stdout.write (self.BLUE + "Word at position: " + aword + "\n" + self.ENDCOL)
+ clue = raw_input (self.BRICKRED + "Clue for word: " + self.ENDCOL)
+ if clue:
+ self.puzzle.data[arow][acol].clue_across = clue
+ sys.stdout.write (self.BLUE + "Set clue: \n" + self.puzzle.data[arow][acol].clue_across)
+ except crosswordpuzzle.NoWordException:
+ sys.stderr.write ("No across word found at that position")
+
+ # add a word to the puzzle
+ def add_word (self, across=True):
+ # first display the grid
+ self.print_puzzle ()
+ # get the row and column
+ srow = raw_input (self.BRICKRED + "Start row: " + self.ENDCOL)
+ scol = raw_input (self.BRICKRED + "Start col: " + self.ENDCOL)
+ # try converting it to number
+ try:
+ row = int (srow)
+ col = int (scol)
+ except ValueError:
+ sys.stderr.write ("Invalid row or column\n")
+ return
+ # get the word
+ word = raw_input (self.BRICKRED + "Word: " + self.ENDCOL)
+
+ # try to add the word to the puzzle grid
+ try:
+ if across == True:
+ self.puzzle.set_word_across (row, col, word)
+ else:
+ self.puzzle.set_word_down (row, col, word)
+ except crosswordpuzzle.TooLongWordException:
+ sys.stderr.write ("Word is too long to fit in the grid! Aborting.\n")
+ except crosswordpuzzle.IntersectWordException:
+ sys.stderr.write ("Word intersects badly with another word!\n")
+ except crosswordpuzzle.FrozenGridException:
+ sys.stderr.write ("Word cannot be added to a frozen puzzle.\n")