(self, widget, first_node=False)
| 538 | return code_nested |
| 539 | |
| 540 | def export_widget_for_app_template(self, widget, first_node=False): |
| 541 | if first_node: |
| 542 | self.code_declared_classes = {} |
| 543 | self.pending_listener_registration = list() |
| 544 | # a list containing widgets that have been parsed and that are considered valid listeners |
| 545 | self.known_project_children = [self, ] |
| 546 | # a list containing dicts {listener, emitter, register_function, listener_function} |
| 547 | self.pending_signals_to_connect = list() |
| 548 | self.path_to_this_widget = [] |
| 549 | self.prepare_path_to_this_widget(self.children['root']) |
| 550 | self.known_project_children.append(widget) |
| 551 | |
| 552 | widget.path_to_this_widget.append(widget.variable_name) |
| 553 | |
| 554 | code_nested = '' # the code strings to return |
| 555 | |
| 556 | if not hasattr(widget, 'attributes'): |
| 557 | return '' # no nested code |
| 558 | |
| 559 | widgetVarName = widget.variable_name |
| 560 | classname = 'CLASS' + \ |
| 561 | widgetVarName if widget.attr_editor_newclass else widget.__class__.__name__ |
| 562 | |
| 563 | if not first_node: |
| 564 | code_nested = prototypes.proto_widget_allocation % { |
| 565 | 'varname': widgetVarName, 'classname': classname} |
| 566 | |
| 567 | for x, y in inspect.getmembers(widget.__class__): |
| 568 | if type(y) == property and not getattr(widget, x) is None: |
| 569 | if hasattr(y.fget, "editor_attributes"): #if this property is visible for the editor |
| 570 | _value = getattr(widget, x) |
| 571 | if type(_value) == str: |
| 572 | _value = '"%s"' % _value |
| 573 | code_nested += prototypes.proto_property_setup % { |
| 574 | 'varname': 'self' if first_node else widgetVarName, 'property': x, 'value': _value} |
| 575 | else: |
| 576 | #eventually, properties have to be placed in the container constructor |
| 577 | pass |
| 578 | |
| 579 | # for all the methods of this widget |
| 580 | for (setOnEventListenerFuncname, setOnEventListenerFunc) in inspect.getmembers(widget): |
| 581 | # if the member is decorated by decorate_set_on_listener |
| 582 | if issubclass(type(setOnEventListenerFunc), gui.ClassEventConnector): |
| 583 | # if there is a callback |
| 584 | if not setOnEventListenerFunc.callback is None and hasattr(setOnEventListenerFunc.event_method_bound, '_event_info'): |
| 585 | listenerFunction = setOnEventListenerFunc.callback |
| 586 | if issubclass(type(listenerFunction), gui.ClassEventConnector): |
| 587 | listenerFunction = listenerFunction.event_method_bound |
| 588 | |
| 589 | listenerPrototype = setOnEventListenerFunc.event_method_bound._event_info[ |
| 590 | 'prototype'] |
| 591 | listener = listenerFunction.__self__ |
| 592 | |
| 593 | # setOnEventListenerFunc._event_info['name'] + "_" + widget.identifier |
| 594 | listenerFunctionName = listenerFunction.__name__ |
| 595 | |
| 596 | listenerClassFunction = prototypes.proto_code_function % {'funcname': listenerFunctionName, |
| 597 | 'parameters': listenerPrototype} |
no test coverage detected