def __construct__(self): #extract, contain, and properly indent python content funcname = self._elem.getAttribute('name') args = self._elem.getAttribute('args') script = Nodes.normalize_python(node=self, definition="def %s(%s):"%(funcname, args)) #run the code (which will define a function where we need it) try: exec script in self.parent.__dict__ except Exception, msg: Events.Error(self, msg, "bad syntax in python block")
def __construct__(self): #extract, contain, and properly indent python content funcname = self._elem.getAttribute('name') args = self._elem.getAttribute('args') prefix = "def %s(%s): import threading; t = threading.Thread(target=_thread_%s, args=[%s]); t.setDaemon(True); t.start();"%(funcname, args, funcname, args) definitionLine = "def _thread_%s(%s):"%(funcname, args) script = Nodes.normalize_python(node=self, prefix=prefix, definition=definitionLine) #run the code (which will define a function where we need it) try: exec script in self.parent.__dict__ except Exception, msg: Events.Error(self, msg, "bad syntax in python block\s%s"%script)
def __construct__(self): #extract, wrap, and properly indent python content self.funcname = self['name'] or "_%s_%s"%(self.on, self.canvas._uidcount) self.canvas.__dict__['_uidcount'] += 1 args = self['args'] or "value" script = Nodes.normalize_python(node=self, definition="def %s(%s):"%(self.funcname, args)) #run the code (which will define a function where we need it) try: exec script in self.parent.__dict__ except Exception, msg: Events.Error(self, msg, "bad syntax in python block") #if a reference is given adjust the target to that, otherwise use the parent per normal if self['reference']: self.parent.constrain(attr='early', func=self._reference) else: self.parent.constrain(attr=self.on, func=self.parent.__dict__[self.funcname])
def __construct__(self): #extract and properly indent python content script = Nodes.normalize_python(node=self) #run th' junks try: exec script in self.parent.__dict__ except Exception, msg: Events.Error(self, msg, "bad syntax in python block")