def main(arg_list): """Parse the command line options and arguments specified in arg_list. Run either the command line user interface, the graphical user interface, or display the usage message. """ usage_message = ("Usage:\n" "Show help: logsim.py -h\n" "Command line user interface: logsim.py -c <file path>\n" "Graphical user interface: logsim.py <file path>") try: options, arguments = getopt.getopt(arg_list, "hc:") except getopt.GetoptError: print("Error: invalid command line arguments\n") print(usage_message) sys.exit() # Initialise instances of the four inner simulator classes names = Names() devices = Devices(names) network = Network(names, devices) monitors = Monitors(names, devices, network) for option, path in options: if option == "-h": # print the usage message print(usage_message) sys.exit() elif option == "-c": # use the command line user interface scanner = Scanner(path, names) parser = Parser(names, devices, network, monitors, scanner) if parser.parse_network(): # Initialise an instance of the userint.UserInterface() class userint = UserInterface(names, devices, network, monitors) userint.command_interface() if not options: # no option given, use the graphical user interface if len(arguments) != 1: # wrong number of arguments print("Error: one file path required\n") print(usage_message) sys.exit() [path] = arguments scanner = Scanner(path, names) parser = Parser(names, devices, network, monitors, scanner) if parser.parse_network(): # Initialise an instance of the gui.Gui() class app = wx.App() builtins._ = wx.GetTranslation locale = wx.Locale() locale.Init(wx.LANGUAGE_DEFAULT) locale.AddCatalogLookupPathPrefix('./locale') locale.AddCatalog('zh_CN') gui = Gui("Logic Simulator", path, names, devices, network, monitors) gui.Show(True) app.MainLoop()
def main(arg_list): """Parse the command line options and arguments specified in arg_list. Run either the command line user interface, the graphical user interface, or display the usage message. """ usage_message = ("Usage:\n" "Show help: logsim.py -h\n" "Command line user interface: logsim.py -c <file path>\n" "Graphical user interface: logsim.py <file path>") try: options, arguments = getopt.getopt(arg_list, "hc:") except getopt.GetoptError: print("Error: invalid command line arguments\n") print(usage_message) sys.exit() # Initialise instances of the four inner simulator classes names = Names() devices = Devices(names) network = Network(names, devices) monitors = Monitors(names, devices, network) for option, path in options: if option == "-h": # print the usage message print(usage_message) sys.exit() elif option == "-c": # use the command line user interface scanner = Scanner(path, names) parser = Parser(names, devices, network, monitors, scanner) if parser.parse_network(): # Initialise an instance of the userint.UserInterface() class userint = UserInterface(names, devices, network, monitors) userint.command_interface() if not options: # no option given, use the graphical user interface # Initialise an instance of the gui.Gui() class app = wx.App() gui = Gui("Logic Simulator") # gui = Gui("Logic Simulator", None, names, devices, network, monitors) gui.Show(True) app.MainLoop()
def main(arg_parser): """Parse the command line options and arguments specified in arg_list. Run either the command line user interface, the graphical user interface, or display the usage message. """ # Add check to see if path leads to a .txt file if arg_parser.path is not None: if arg_parser.path[-3:] != "txt": raise TypeError("***ERROR: Please load in a .txt file") # Check if user tries to input translation into command line # interface if arg_parser.c and arg_parser.r: print("Cannot launch command line mode with translator") sys.exit() # Initialise instances of the four inner simulator classes names = Names() devices = Devices(names) network = Network(names, devices) monitors = Monitors(names, devices, network) scanner = Scanner(arg_parser.path, names) parser = Parser(names, devices, network, monitors, scanner) if parser.parse_network(): if arg_parser.c: # Initialise instance of the userint.UserInterface() class userint = UserInterface(names, devices, network, monitors) userint.command_interface() else: if arg_parser.r: lang = u"el" else: lang = u"en" # Initialise an instance of the gui.Gui() class file_name = get_file_name(arg_parser.path) title = "Logic Simulator - " + file_name app = wx.App() gui = Gui(title, arg_parser.path, names, devices, network, monitors, lang) gui.Show(True) app.MainLoop()
def main(arg_list): """Parse the command line options and arguments specified in arg_list. Run either the command line user interface, the graphical user interface, or display the usage message. """ usage_message = ("Usage:\n" "Show help: logsim.py -h\n" "Command line user interface: logsim.py -c <file path>\n" "Graphical user interface: logsim.py <file path>") try: options, arguments = getopt.getopt(arg_list, "hc:") except getopt.GetoptError: print("Error: invalid command line arguments\n") print(usage_message) sys.exit() for option, path in options: if option == "-h": # print the usage message print(usage_message) sys.exit() elif option == "-c": # use the command line user interface names = Names() devices = Devices(names) network = Network(names, devices) monitors = Monitors(names, devices, network) scanner = Scanner(path, names) parser = Parser(names, devices, network, monitors, scanner) if parser.parse_network(): error_list = scanner.error_list for error in error_list: print(error) # Initialise an instance of the userint.UserInterface() class userint = UserInterface(names, devices, network, monitors) userint.command_interface() else: error_list = scanner.error_list for error in error_list: print(error) if not options: # no option given, use the graphical user interface path = None names = None devices = None network = None monitors = None filename = None app = wx.App() # Internationalisation builtins._ = wx.GetTranslation locale = wx.Locale() locale.Init(wx.LANGUAGE_DEFAULT) locale.AddCatalogLookupPathPrefix('./locale') locale.AddCatalog('messages') gui = Gui(_("பனி Logic Simulator"), path, names, devices, network, monitors, filename, True) gui.Show(True) gui.startup_load() app.MainLoop() while gui.load_new is True: path = gui.current_pathname filename = gui.current_filename names = Names() devices = Devices(names) network = Network(names, devices) monitors = Monitors(names, devices, network) scanner = Scanner(path, names) parser = Parser(names, devices, network, monitors, scanner) if parser.parse_network(): # Initialise an instance of the gui.Gui() class gui = Gui( _("பனி Logic Simulator - {}").format(filename), path, names, devices, network, monitors, filename) gui.Show(True) app.MainLoop()
def main(arg_list): """Parse the command line options and arguments specified in arg_list. Run either the command line user interface, the graphical user interface, or display the usage message. """ usage_message = ("Usage:\n" "Show help: logsim.py -h\n" "Command line user interface: logsim.py -c <file path>\n" "Graphical user interface: logsim.py <file path>") try: options, arguments = getopt.getopt(arg_list, "hc:") except getopt.GetoptError: print("Error: invalid command line arguments\n") print(usage_message) sys.exit() # Initialise instances of the four inner simulator classes names = Names() devices = Devices(names) network = Network(names, devices) monitors = Monitors(names, devices, network) for option, path in options: if option == "-h": # print the usage message print(usage_message) sys.exit() elif option == "-c": # use the command line user interface scanner = Scanner(path, names) parser = Parser(names, devices, network, monitors, scanner) if parser.parse_network(): # Initialise an instance of the userint.UserInterface() class userint = UserInterface(names, devices, network, monitors) userint.command_interface() if not options: # no option given, use the graphical user interface if len(arguments) != 1: # wrong number of arguments print("Error: one file path required\n") print(usage_message) sys.exit() [path] = arguments scanner = Scanner(path, names) parser = Parser(names, devices, network, monitors, scanner) if parser.parse_network(): # Initialise an instance of the gui.Gui() class app = wx.App() gui = Gui("Logic Simulator", path, names, devices, network, monitors) gui.Show(True) app.MainLoop() while hasattr(gui, 'edit_restart'): # GUI terminated and set the edit_restart flag. # We open the file in an editor to allow the user # to change the file, then restart the GUI. del app run_editor(path) # Re-initialise everything names = Names() devices = Devices(names) network = Network(names, devices) monitors = Monitors(names, devices, network) scanner = Scanner(path, names) parser = Parser(names, devices, network, monitors, scanner) if parser.parse_network(): app = wx.App() gui = Gui("Logic Simulator", path, names, devices, network, monitors) gui.Show(True) app.MainLoop() else: # Parser error messages would be enough, no need to # re-inform users of parser failure. break
import os from gui import Gui from event_handler import EventHandler DEBUG = 50 # 1 - Apresentar Dict vertices e edges # 2 - Apresentar Adjs e cor # 3 - Apresentar Predecessor e Estimativa # 50 - Auto colocar vertices if "DEBUG" in os.environ: DEBUG = int(os.environ["DEBUG"]) W_SIZE = 1080 H_SIZE = 720 g = Gui(None, title="Trb M3 - Grafos", size=(W_SIZE, H_SIZE)) e = EventHandler(g, DEBUG) g.set_evt_handler(e) g.add_menu_bar() g.Show() g.main_loop()
def main(arg_list): """Parse the command line options and arguments specified in arg_list. Run either the command line user interface, the graphical user interface, or display the usage message. """ usage_message = ( "Usage:\n" "Show help: logsim.py -h\n" "Command line user interface: logsim.py -c <file path>\n" "Graphical user interface: logsim.py <file path> or logsim.py") try: options, arguments = getopt.getopt(arg_list, "hc:") except getopt.GetoptError: print("Error: invalid command line arguments\n") print(usage_message) sys.exit() # Initialise instances of the four inner simulator classes names = Names() devices = Devices(names) network = Network(names, devices) monitors = Monitors(names, devices, network) #device = Device(self.names.lookup([names])) #names = None #devices = None #network = None #monitors = None for option, path in options: if option == "-h": # print the usage message print(usage_message) sys.exit() elif option == "-c": # use the command line user interface scanner = Scanner(path, names) parser = Parser(names, devices, network, monitors, scanner) if parser.parse_network(): # Initialise an instance of the userint.UserInterface() class userint = UserInterface(names, devices, network, monitors) userint.command_interface() if not options: # no option given, use the graphical user interface app = ab.BaseApp(redirect=False) error = ErrorFrame() if len(arguments) == 0: # wrong number of arguments # Initialise an instance of the gui.Gui() class path = None #print('len(arguments) = 0 if statement is accessed') scanner = Scanner(path, names) parser = Parser(names, devices, network, monitors, scanner) gui = Gui("LogicSim", path, names, devices, network, monitors) gui.Show(True) elif len(arguments) != 0 and len(arguments) != 1: print("Error: one or no file path required\n") print(usage_message) sys.exit() else: [path] = arguments scanner = Scanner(path, names) parser = Parser(names, devices, network, monitors, scanner) if parser.parse_network(): # Initialise an instance of the gui.Gui() class #import app_base as ab #app = ab.BaseApp(redirect=False) #app = wx.App() gui = Gui("LogicSim", path, names, devices, network, monitors) gui.Show(True) error.ShowModal() app.MainLoop()
def main(arg_list): """Parse the command line options and arguments specified in arg_list. Run either the command line user interface, the graphical user interface, or display the usage message. """ usage_message = ( "Usage:\n" "Show help: logsim.py -h\n" "Command line user interface: logsim.py -c <file path>\n" "Graphical user interface with a blank circuit: logsim.py\n" "Graphical user interface with a predefined test circuit: logsim.py -t <circuit_number>\n" "Graphical user interface with loading a file: logsim.py <file path>") try: options, arguments = getopt.getopt(arg_list, "hct:") except getopt.GetoptError: print("Error: invalid command line arguments\n") print(usage_message) sys.exit() # Initialise instances of the four inner simulator classes names = Names() devices = Devices(names) network = Network(names, devices) monitors = Monitors(names, devices, network) import app_base as ab for option, path in options: if option == "-h": # print the usage message print(usage_message) sys.exit() elif option == "-c": # use the command line user interface scanner = Scanner(path, names) parser = Parser(names, devices, network, monitors, scanner) if parser.parse_network(): # Initialise an instance of the userint.UserInterface() class userint = UserInterface(names, devices, network, monitors) userint.command_interface() elif option == "-t": # manually create the devices, network, and monitors for testing if path == "1": names, devices, network, monitors = test_1() elif path == "2": names, devices, network, monitors = test_2() elif path == "3": names, devices, network, monitors = test_3() elif path == "4": names, devices, network, monitors = test_4() else: print("Error: invalid test number.\n") sys.exit() # Initialise an instance of the gui.Gui() class app = wx.App() gui = Gui("Logic Simulator", path, names, devices, network, monitors, "en", 0) gui.Show(True) app.MainLoop() if not options: # no option given, use the graphical user interface if len(arguments) == 0: # Open the blank gui # Initialise an instance of the gui.Gui() class app = wx.App() gui = Gui("Logic Simulator", None, names, devices, network, monitors, "en", 0) gui.Show(True) app.MainLoop() elif len(arguments) == 1: [path] = arguments scanner = Scanner(path, names) parser = Parser(names, devices, network, monitors, scanner) if parser.parse_network(): # Initialise an instance of the gui.Gui() class app = wx.App() gui = Gui("Logic Simulator", path, names, devices, network, monitors, "en", 0) gui.Show(True) app.MainLoop() else: # wrong number of arguments print("Error: Too many arguments given\n") print(usage_message) sys.exit()
def main(): app = wx.App() gui = Gui('Subtitle Shifter') gui.Show(True) app.MainLoop()