def generate(): statement = coremeraco.constructRegularStatement() + os.linesep textArea.insert(Tkinter.END, statement) textArea.yview(Tkinter.END) if (saveOutputState.get()): try: outputFileHandler = open(saveOutputDestination.get(), 'a') # 'a' means append mode outputFileHandler.write(statement) outputFileHandler.close() except IOError as Argument: tkMessageBox.showerror(productName, meracolocale.getLocalisedString(localisationFile, "ioErrorMessage") + str(Argument)) except Exception as Argument: tkMessageBox.showerror(productName, meracolocale.getLocalisedString(localisationFile, "genericErrorMessage") + str(Argument))
# Copyright 2016, 2017 Declan Hoare # This file is part of Merac-O-Matic. # # Merac-O-Matic is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Merac-O-Matic is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Merac-O-Matic. If not, see <http://www.gnu.org/licenses/>. # # This program allows the user to control Merac-O-Matic from a text # environment. import coremeraco, argparse, meracolocale localisationFile = meracolocale.getAndParseLocalisationFile() parser = argparse.ArgumentParser(description=meracolocale.getLocalisedString(localisationFile,"productDescription")) parser.add_argument('--exit', dest='exitStatement', action='store_const', const='exit', default='regular', help=meracolocale.getLocalisedString(localisationFile,"exitHelpText")) args = parser.parse_args() if args.exitStatement == 'exit': print(coremeraco.constructExitStatement()) else: print(coremeraco.constructRegularStatement())
# environment. It will also try to integrate with Festival to optionally # read out the output, but this is not implemented yet. # Try doing things the Python 2 way first. If that throws an exception, # we're obviously on Python 3 (ugh), so work around its stupidity. Have # I mentioned I don't like Python 3? try: import Tkinter, tkMessageBox, tkFileDialog except Exception: import tkinter as Tkinter import tkinter.messagebox as tkMessageBox import tkinter.filedialog as tkFileDialog import coremeraco, os, meracolocale, ReadOnlyText, sys localisationFile = meracolocale.getAndParseLocalisationFile() productName = meracolocale.getLocalisedString(localisationFile, "productName") mainWindow = Tkinter.Tk() mainWindow.title(productName) try: meracoIcon = Tkinter.PhotoImage(file=os.path.join(meracolocale.getProgramLocation(), 'meraco.png')) mainWindow.tk.call('wm', 'iconphoto', mainWindow._w, meracoIcon) except Exception: # PhotoImage doesn't work on some setups, so we'll try iconbitmap try: mainWindow.iconbitmap(os.path.join(meracolocale.getProgramLocation(), 'meraco.ico')) except Exception: # If that doesn't work either for some reason, there's still no sense ending the program! print(meracolocale.getLocalisedString(localisationFile, "iconWarning")) displayFrame = Tkinter.Frame(mainWindow)