aword, arow, acol, alen = self.puzzle.get_word_across (row, col)
sys.stdout.write (self.BLUE + "Across word at position: " + aword + "\n" + self.ENDCOL)
clue = raw_input (self.BRICKRED + "Clue for across 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)
+ self.puzzle.data[arow][acol].clue_across = clue
+ sys.stdout.write (self.BLUE + "Set the clue: \n" + self.puzzle.data[arow][acol].clue_across)
except crosswordpuzzle.NoWordException:
sys.stderr.write ("No across word found at that position\n")
dword, drow, dcol, dlen = self.puzzle.get_word_down (row, col)
sys.stdout.write (self.BLUE + "Down word at position: " + dword + "\n" + self.ENDCOL)
clue = raw_input (self.BRICKRED + "Clue for down word: " + self.ENDCOL)
- if clue:
- self.puzzle.data[drow][dcol].clue_down = clue
- sys.stdout.write (self.BLUE + "Set clue: \n" + self.puzzle.data[drow][dcol].clue_down)
+ self.puzzle.data[drow][dcol].clue_down = clue
+ sys.stdout.write (self.BLUE + "Set the clue: \n" + self.puzzle.data[drow][dcol].clue_down)
except crosswordpuzzle.NoWordException:
sys.stderr.write ("No down word found at that position\n")
sys.stdout.write ("7. Unfreeze grid\n")
sys.stdout.write ("8. Set clue for word\n")
sys.stdout.write ("9. Display clues\n")
+ sys.stdout.write ("R. Reset grid\n")
sys.stdout.write ("S. Save puzzle\n")
sys.stdout.write ("E. Export to AcrossLite(TM) format\n")
sys.stdout.write ("H. Export puzzle as image/HTML\n")
self.on_set_clue ()
elif ch == "9":
self.on_display_clues ()
+ elif ch == "R" or ch == "r":
+ self.on_reset_grid ()
elif ch == "S" or ch == "s":
self.save_puzzle ()
elif ch == "E" or ch == "e":
self.load_puzzle ()
self.do_puzzle_loop ()
+ # when user chooses to reset grid
+ def on_reset_grid (self):
+ ans = raw_input (self.BRICKRED +
+ "This will clear the entire grid! Are you sure (Y/N)? " + self.ENDCOL)
+ if ans == "y" or ans == "Y":
+ self.puzzle.reset_grid ()
+ sys.stdout.write (self.BLUE + "Grid has been cleared of all data!"
+ + self.ENDCOL + "\n")
+
# Main application loop
def do_main_loop (self):
# display the menu