MCPcopy Index your code
hub / github.com/rawpython/remi / repr_widget_for_editor

Method repr_widget_for_editor

editor/editor.py:424–538  ·  view source on GitHub ↗
(self, widget, first_node=False)

Source from the content-addressed store, hash-verified

422
423 # widgetVarName is the name with which the parent calls this instance
424 def repr_widget_for_editor(self, widget, first_node=False):
425 if first_node:
426 self.code_declared_classes = {}
427 self.pending_listener_registration = list()
428 # a list containing widgets that have been parsed and that are considered valid listeners
429 self.known_project_children = [self, ]
430 # a list containing dicts {listener, emitter, register_function, listener_function}
431 self.pending_signals_to_connect = list()
432 self.path_to_this_widget = []
433 self.prepare_path_to_this_widget(self.children['root'])
434 self.known_project_children.append(widget)
435
436 widget.path_to_this_widget.append(widget.variable_name)
437
438 print(widget.variable_name)
439
440 code_nested = '' # the code strings to return
441
442 if not hasattr(widget, 'attributes'):
443 return '' # no nested code
444
445 widgetVarName = widget.variable_name
446 classname = 'CLASS' + \
447 widgetVarName if widget.attr_editor_newclass else widget.__class__.__name__
448
449 code_nested = prototypes.proto_widget_allocation % {
450 'varname': widgetVarName, 'classname': classname}
451
452 #code_nested += prototypes.proto_attribute_setup%{'varname': widgetVarName, 'attr_dict': ','.join('"%s":"%s"'%(key,widget.attributes[key]) for key in widget.attributes.keys() if key not in html_helper.htmlInternallyUsedTags)}
453 #code_nested += prototypes.proto_style_setup%{'varname': widgetVarName, 'style_dict': ','.join('"%s":"%s"'%(key,widget.style[key]) for key in widget.style.keys())}
454
455 for x, y in inspect.getmembers(widget.__class__):
456 if type(y) == property and not getattr(widget, x) is None:
457 if hasattr(y.fget, "editor_attributes"): #if this property is visible for the editor
458 _value = getattr(widget, x)
459 if type(_value) == type('') or type(_value) == type(u''):
460 _value = '"%s"' % _value
461 code_nested += prototypes.proto_property_setup % {
462 'varname': widgetVarName, 'property': x, 'value': _value}
463
464 # for all the methods of this widget
465 for (setOnEventListenerFuncname, setOnEventListenerFunc) in inspect.getmembers(widget):
466 # if the member is decorated by decorate_set_on_listener
467 if issubclass(type(setOnEventListenerFunc), gui.ClassEventConnector):
468 # if there is a callback
469 if not setOnEventListenerFunc.callback is None and hasattr(setOnEventListenerFunc.event_method_bound, '_event_info'):
470 listenerFunction = setOnEventListenerFunc.callback
471 if issubclass(type(listenerFunction), gui.ClassEventConnector):
472 listenerFunction = listenerFunction.event_method_bound
473
474 listenerPrototype = setOnEventListenerFunc.event_method_bound._event_info[
475 'prototype']
476 listener = listenerFunction.__self__
477
478 # setOnEventListenerFunc._event_info['name'] + "_" + widget.identifier
479 listenerFunctionName = listenerFunction.__name__
480
481 listenerClassFunction = prototypes.proto_code_function % {'funcname': listenerFunctionName,

Callers 3

saveMethod · 0.95

Calls 3

appendMethod · 0.45

Tested by

no test coverage detected