def generate_widget_class(self, uidef, target, **kw): self.uidefinition = uidef self._process_options(kw) mastermeta = wmeta = self.uidefinition.get_widget(target) builder = bmaster = BuilderObject(self, mastermeta) if wmeta is not None: originalid = wmeta.identifier wmeta.identifier = 'self' if wmeta.classname not in CLASS_MAP: self._builder._import_class(wmeta.classname) if wmeta.classname in CLASS_MAP: bclass = CLASS_MAP[wmeta.classname].builder builder = bclass.factory(self, wmeta) uniqueid = builder.code_identifier() masterid = bmaster.code_child_master() for childmeta in \ self.uidefinition.widget_children(target): childid = self._code_realize(builder, childmeta) code = builder.code_child_add(childid) self._code.extend(code) return self._process_results(target)
def code_translate_str(self, value: str) -> str: escaped = BuilderObject.code_escape_str(value) if self.with_i18n_support: trval = f'_({escaped})' return trval else: return escaped
def get_object(self, name, master=None): """Find and create the widget named name. Use master as parent. If widget was already created, return that instance.""" widget = None if name in self.objects: widget = self.objects[name].widget else: wmeta = self.uidefinition.get_widget(name) if wmeta is not None: rmeta = WidgetMeta('root', 'root') root = BuilderObject(self, rmeta) root.widget = master bobject = self._realize(root, wmeta) widget = bobject.widget if widget is None: msg = 'Widget "{0}" not defined.'.format(name) raise Exception(msg) return widget
def generate(self, uidef, target, **kw): self.uidefinition = uidef self._process_options(kw) mastermeta = WidgetMeta('', 'master') builder = BuilderObject(self, mastermeta) wmeta = self.uidefinition.get_widget(target) if wmeta is not None: self._code_realize(builder, wmeta) return self._process_results(target)