def command_line_code_generation(filename, language, out_path=None): """Starts a code generator without starting the GUI. filename: Name of wxg file to generate code from language: Code generator language out_path: output file / output directory""" from main import wxGlade app = wxGlade() if filename is not None: win = app.GetTopWindow() win._open_app(filename, False) win.cur_dir = os.path.dirname(filename) try: if language not in common.code_writers: raise errors.WxgMissingCodeWriter(language) common.app_tree.app.properties["language"].set(language) common.app_tree.app.generate_code(out_path=out_path) except errors.WxgBaseException as inst: logging.error(inst) sys.exit(inst) except Exception: logging.error( _("An exception occurred while generating the code for the application.\n" "If you think this is a wxGlade bug, please report it.")) logging.exception(_('Internal Error')) sys.exit(1) sys.exit(0)
def command_line_code_generation(filename, language, out_path=None): """Starts a code generator without starting the GUI. filename: Name of wxg file to generate code from language: Code generator language out_path: output file / output directory""" import application, tree # Instead of instantiating a main.wxGlade() object, that is # derived from wx.App, we must do the equivalent work. The # following lines are taken from main.wxGlade().OnInit() and # main.wxGladeFrame.__init__() common.init_preferences() common.root = app = application.Application() # The following lines contain code from tree.WidgetTree.__init__() if config.use_gui: common.app_tree = tree.WidgetTree(root_node, app) # Now we can load the file if filename is not None: b = _guiless_open_app(filename) if not b: sys.exit(1) try: if language not in common.code_writers: raise errors.WxgMissingCodeWriter(language) common.root.properties["language"].set(language) common.root.generate_code(out_path=out_path) except errors.WxgBaseException as inst: if config.debugging: raise logging.error(inst) sys.exit(inst) except Exception: if config.debugging: raise logging.error( _("An exception occurred while generating the code for the application.\n" "If you think this is a wxGlade bug, please report it.")) logging.exception(_('Internal Error')) sys.exit(1) sys.exit(0)
def command_line_code_generation(filename, language, out_path=None): """Starts a code generator without starting the GUI. filename: Name of wxg file to generate code from language: Code generator language out_path: output file / output directory""" from xml_parse import CodeWriter try: if language not in common.code_writers: raise errors.WxgMissingCodeWriter(language) writer = common.code_writers[language] CodeWriter( writer=writer, input=filename, out_path=out_path ) except errors.WxgBaseException as inst: logging.error(inst) sys.exit(inst) except Exception: logging.error( _("An exception occurred while generating the code for the application.\n" "If you think this is a wxGlade bug, please report it.") ) logging.exception(_('Internal Error')) sys.exit(1) sys.exit(0)