X-Git-Url: https://harishankar.org/repos/?p=getaclue.git;a=blobdiff_plain;f=crosswordpuzzlecreator.py;fp=crosswordpuzzlecreator.py;h=1e62315ecd42f6fc4fb71ca8962e412a55e39455;hp=5a0ae119a1a8b3dc32576354553a0ee8f75073b0;hb=5f68ccac12372c5271c21e9045558d2d03e92a41;hpb=8bf14bbd585036c0cfda88c2ace825f1aa471730 diff --git a/crosswordpuzzlecreator.py b/crosswordpuzzlecreator.py index 5a0ae11..1e62315 100644 --- a/crosswordpuzzlecreator.py +++ b/crosswordpuzzlecreator.py @@ -146,9 +146,8 @@ class CrosswordPuzzleCreator: 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") @@ -157,9 +156,8 @@ class CrosswordPuzzleCreator: 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") @@ -251,6 +249,7 @@ class CrosswordPuzzleCreator: 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") @@ -271,6 +270,8 @@ class CrosswordPuzzleCreator: 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": @@ -304,6 +305,15 @@ class CrosswordPuzzleCreator: 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