X-Git-Url: https://harishankar.org/repos/?p=getaclue.git;a=blobdiff_plain;f=crosswordpuzzlecreator.py;h=5a0ae119a1a8b3dc32576354553a0ee8f75073b0;hp=710de09fb26c771efc87e8bd96b5aff8732c6bb2;hb=8bf14bbd585036c0cfda88c2ace825f1aa471730;hpb=2f775ee1c4d2c260221155494b2c7856bc38dafd diff --git a/crosswordpuzzlecreator.py b/crosswordpuzzlecreator.py index 710de09..5a0ae11 100644 --- a/crosswordpuzzlecreator.py +++ b/crosswordpuzzlecreator.py @@ -193,6 +193,26 @@ class CrosswordPuzzleCreator: except crosswordpuzzle.FrozenGridException: sys.stderr.write ("Word cannot be added to a frozen puzzle.\n") + # Export to image/HTML + def on_export_image (self, solution=True): + try: + sys.stdout.write (self.BLUE + "Exporting puzzle to image/HTML\n") + pngfile = raw_input (self.BRICKRED + "Filename (PNG): " + self.ENDCOL) + if solution is False: + htmlfile = raw_input (self.BRICKRED + "Filename (HTML): " + + self.ENDCOL) + puztitle = raw_input (self.BRICKRED + "Title of puzzle: " + + self.ENDCOL) + self.puzzle.export_image (pngfile, htmlfile, puztitle, solution) + else: + self.puzzle.export_image (pngfile) + + sys.stdout.write (self.BLUE + "Successfully exported!") + except crosswordpuzzle.FrozenGridException: + sys.stderr.write ("Cannot export as grid is not frozen/finalized\n") + except crosswordpuzzle.NoWordsException: + sys.stderr.write ("No words to export!\n") + # Export to across lite def on_export_acrosslite (self): try: @@ -233,6 +253,8 @@ class CrosswordPuzzleCreator: sys.stdout.write ("9. Display clues\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") + sys.stdout.write ("I. Export solution as image\n") sys.stdout.write ("X. Exit to main menu\n" + self.ENDCOL) ch = raw_input (self.BRICKRED + "Your choice: " + self.ENDCOL) if ch == "1": @@ -253,6 +275,10 @@ class CrosswordPuzzleCreator: self.save_puzzle () elif ch == "E" or ch == "e": self.on_export_acrosslite () + elif ch == "H" or ch == "h": + self.on_export_image (False) + elif ch == "I" or ch == "i": + self.on_export_image () elif ch == "X" or ch == "x": break