def AddNode(self, parent, node): # Append tree item try: comp = Manager.getNodeComp(node, None) className = comp.klass except: className = node.getAttribute('class') # Try to create some generic component on-the-fly attributes = [] isContainer = False for n in node.childNodes: if is_object(n): isContainer = True elif n.nodeType == node.ELEMENT_NODE and not n.tagName in attributes: attributes.append(n.tagName) if isContainer: comp = Container(className, 'unknown', attributes) else: comp = Component(className, 'unknown', attributes) Manager.register(comp) wx.LogWarning('Unknown component class "%s", registered as generic' % className) item = self.AppendItem(parent, comp.getTreeText(node), image=comp.getTreeImageId(node), data=wx.TreeItemData(node)) self.SetItemStyle(item, node) # Try to find children objects if comp.isContainer(): for n in filter(is_object, node.childNodes): self.AddNode(item, comp.getTreeNode(n))
def AddNode(self, parent, node): # Append tree item try: comp = Manager.getNodeComp(node, None) className = comp.klass except: className = node.getAttribute('class') # Try to create some generic component on-the-fly attributes = [] isContainer = False for n in node.childNodes: if is_object(n): isContainer = True elif n.nodeType == node.ELEMENT_NODE and not n.tagName in attributes: attributes.append(n.tagName) if isContainer: comp = Container(className, 'unknown', attributes) else: comp = Component(className, 'unknown', attributes) Manager.register(comp) wx.LogWarning( 'Unknown component class "%s", registered as generic' % className) item = self.AppendItem(parent, comp.getTreeText(node), image=comp.getTreeImageId(node), data=wx.TreeItemData(node)) self.SetItemStyle(item, node) # Try to find children objects if comp.isContainer(): for n in filter(is_object, node.childNodes): self.AddNode(item, comp.getTreeNode(n))
def AddNode(self, parent, node): # Append tree item try: comp = Manager.getNodeComp(node, None) className = comp.klass except: className = node.getAttribute('class') # Try to create some generic component on-the-fly attributes = [] isContainer = False for n in node.childNodes: if is_object(n): isContainer = True elif n.nodeType == node.ELEMENT_NODE and not n.tagName in attributes: attributes.append(n.tagName) if isContainer: comp = Container(className, 'unknown', attributes) else: comp = Component(className, 'unknown', attributes) Manager.register(comp) wx.LogWarning( 'Unknown component class "%s", registered as generic' % className) item = self.AppendItem(parent, comp.getTreeText(node), image=comp.getTreeImageId(node), data=wx.TreeItemData(node)) self.SetItemStyle(item, node) # Try to find children objects if comp.isContainer(): for n in filter(is_object, node.childNodes): self.AddNode(item, comp.getTreeNode(n)) elif node.nodeType == node.COMMENT_NODE: if node.data and node.data[0] == '%' and g.conf.allowExec != 'no': if g.conf.allowExec == 'ask' and Model.allowExec is None: say = wx.MessageBox( '''This file contains executable comment directives. \ Allow to execute?''', 'Warning', wx.ICON_EXCLAMATION | wx.YES_NO) if say == wx.YES: Model.allowExec = True else: Model.allowExec = False if g.conf.allowExec == 'yes' or Model.allowExec: code = node.data[1:] # skip '%' try: exec code in globals(), self.locals except: wx.LogError('exec error: "%s"' % code) logger.exception("execution of in-line comment failed")
def AddNode(self, parent, node): # Append tree item try: comp = Manager.getNodeComp(node, None) className = comp.klass except: className = node.getAttribute("class") # Try to create some generic component on-the-fly attributes = [] isContainer = False for n in node.childNodes: if is_element(n): isContainer = True elif n.nodeType == node.ELEMENT_NODE and not n.tagName in attributes: attributes.append(n.tagName) if isContainer: comp = Container(className, "unknown", attributes) else: comp = Component(className, "unknown", attributes) Manager.register(comp) wx.LogWarning('Unknown component class "%s", registered as generic' % className) item = self.AppendItem( parent, comp.getTreeText(node), image=comp.getTreeImageId(node), data=wx.TreeItemData(node) ) self.SetItemStyle(item, node) # Try to find children objects if comp.isContainer(): for n in filter(is_object, node.childNodes): self.AddNode(item, comp.getTreeNode(n)) elif node.nodeType == node.COMMENT_NODE: if node.data and node.data[0] == "%" and g.conf.allowExec != "no": if g.conf.allowExec == "ask" and Model.allowExec is None: say = wx.MessageBox( """This file contains executable comment directives. \ Allow to execute?""", "Warning", wx.ICON_EXCLAMATION | wx.YES_NO, ) if say == wx.YES: Model.allowExec = True else: Model.allowExec = False if g.conf.allowExec == "yes" or Model.allowExec: code = node.data[1:] # skip '%' self.ExecCode(code)
def OnInit(self): if USE_INSPECTOR: self.Init() # Check version if wx.VERSION[:3] < MinWxVersion: wx.LogWarning('''\ This version of XRCed may not work correctly on your version of wxWidgets. \ Please upgrade wxWidgets to %d.%d.%d or higher.''' % MinWxVersion) g.undoMan = undo.UndoManager() Manager.init() parser = OptionParser(prog=progname, version='%s version %s' % (ProgName, version), usage='%prog [options] [XRC file]') parser.add_option('-d', '--debug', action='store_true', help='add Debug command to Help menu') parser.add_option('-m', '--meta', action='store_true', dest='meta', help='activate meta-components') parser.add_option('-v', '--verbose', action='store_true', help='verbose messages') # Process command-line arguments options, args = parser.parse_args() if options.debug: set_debug(True) if options.verbose: set_verbose(True) if options.meta: g.useMeta = True import meta Manager.register(meta.Component) Manager.setMenu(meta.Component, 'TOP_LEVEL', 'component', 'component plugin') self.SetAppName(progname) self.ReadConfig() # Add handlers wx.FileSystem.AddHandler(wx.MemoryFSHandler()) self.toolArtProvider = view.ToolArtProvider() wx.ArtProvider.Push(self.toolArtProvider) # Load standard plugins first plugin.load_plugins(os.path.join(g.basePath, 'plugins')) # ... and then from user-defined dirs plugin.load_plugins_from_dirs() # Setup MVP view.create_view() Presenter.init() Listener.Install(view.frame, view.tree, view.panel, view.toolFrame, view.testWin) if args: path = args[0] # Change current directory dir = os.path.dirname(path) if dir: os.chdir(dir) path = os.path.basename(path) if os.path.isfile(path): Presenter.open(path) else: # Future name Presenter.path = path # Force update title Presenter.setModified(False) view.frame.Show() if not g.useAUI: if not g.conf.embedPanel: view.frame.miniFrame.Show() if g.conf.showToolPanel: Listener.toolFrame.Show() return True
def OnInit(self): # Check version if wx.VERSION[:3] < MinWxVersion: wx.LogWarning('''\ This version of XRCed may not work correctly on your version of wxWidgets. \ Please upgrade wxWidgets to %d.%d.%d or higher.''' % MinWxVersion) g.undoMan = undo.UndoManager() Manager.init() parser = OptionParser(prog=progname, version='%s version %s' % (ProgName, version), usage='%prog [options] [XRC file]') parser.add_option('-d', '--debug', action='store_true', help='add Debug command to Help menu') parser.add_option('-m', '--meta', action='store_true', dest = 'meta', help='activate meta-components') parser.add_option('-v', '--verbose', action='store_true', help='verbose messages') # Process command-line arguments options, args = parser.parse_args() if options.debug: set_debug(True) if options.verbose: set_verbose(True) if options.meta: g.useMeta = True import meta Manager.register(meta.Component) Manager.setMenu(meta.Component, 'TOP_LEVEL', 'component', 'component plugin') self.SetAppName(progname) self.ReadConfig() # Add handlers wx.FileSystem.AddHandler(wx.MemoryFSHandler()) self.toolArtProvider = view.ToolArtProvider() wx.ArtProvider.Push(self.toolArtProvider) # Load standard plugins first plugin.load_plugins(os.path.join(g.basePath, 'plugins')) # ... and then from user-defined dirs plugin.load_plugins_from_dirs() # Setup MVP view.create_view() Presenter.init() Listener.Install(view.frame, view.tree, view.panel, view.toolFrame, view.testWin) if args: path = args[0] # Change current directory dir = os.path.dirname(path) if dir: os.chdir(dir) path = os.path.basename(path) if os.path.isfile(path): Presenter.open(path) else: # Future name Presenter.path = path # Force update title Presenter.setModified(False) view.frame.Show() if not g.useAUI: if not g.conf.embedPanel: view.frame.miniFrame.Show() if g.conf.showToolPanel: Listener.toolFrame.Show() return True