'Create a OWWidget instance for the node.'

def create_widget_instance(self, node):

    desc = node.description
    klass = widget = None
    initialized = False
    error = None
    try:
        klass = name_lookup(desc.qualified_name)
    except (ImportError, AttributeError):
        sys.excepthook(*sys.exc_info())
        error = 'Could    not    import    {0!r}\n\n{1}'.format(node.description.qualified_name, traceback.format_exc())
    except Exception:
        sys.excepthook(*sys.exc_info())
        error = 'An    unexpected    error    during    import    of    {0!r}\n\n{1}'.format(node.description.qualified_name, traceback.format_exc())
    if (klass is None):
        widget = mock_error_owwidget(node, error)
        initialized = True
    if (widget is None):
        log.info("WidgetManager:    Creating    '%s.%s'    instance    '%s'.", klass.__module__, klass.__name__, node.title)
        widget = klass.__new__(klass, None, captionTitle=node.title, signal_manager=self.signal_manager(), stored_settings=node.properties, env=self.scheme().runtime_env())
        initialized = False
    assert (node not in self.__widget_for_node)
    self.__widget_for_node[node] = widget
    self.__node_for_widget[widget] = node
    self.__widget_processing_state[widget] = WidgetManager.Initializing
    self.__initstate_for_node[node] = WidgetManager.PartiallyInitialized(node, widget)
    if (not initialized):
        try:
            widget.__init__()
        except Exception:
            sys.excepthook(*sys.exc_info())
            msg = traceback.format_exc()
            msg = 'Could    not    create    {0!r}\n\n{1}'.format(node.description.name, msg)
            del self.__widget_for_node[node]
            del self.__node_for_widget[widget]
            del self.__widget_processing_state[widget]
            widget = mock_error_owwidget(node, msg)
            self.__widget_for_node[node] = widget
            self.__node_for_widget[widget] = node
            self.__widget_processing_state[widget] = 0
            self.__initstate_for_node[node] = WidgetManager.Materialized(node, widget)
    self.__initstate_for_node[node] = WidgetManager.Materialized(node, widget)
    self.__widget_processing_state[widget] &= (~ WidgetManager.Initializing)
    node.title_changed.connect(widget.setCaption)
    widget.messageActivated.connect(self.__on_widget_state_changed)
    widget.messageDeactivated.connect(self.__on_widget_state_changed)
    node.set_status_message(widget.statusMessage())
    widget.statusMessageChanged.connect(node.set_status_message)
    widget.progressBarValueChanged.connect(node.set_progress)
    widget.processingStateChanged.connect(self.__on_processing_state_changed)
    widget.blockingStateChanged.connect(self.__on_blocking_state_changed)
    if widget.isBlocking():
        self.__widget_processing_state[widget] |= self.BlockingUpdate
    if (widget.processingState != 0):
        self.__widget_processing_state[widget] |= self.ProcessingUpdate
        node.set_processing_state(1)
        node.set_progress(widget.progressBarValue)
    help_shortcut = QShortcut(QKeySequence('F1'), widget)
    help_shortcut.activated.connect(self.__on_help_request)
    up_shortcut = QShortcut(QKeySequence((Qt.ControlModifier + Qt.Key_Up)), widget)
    up_shortcut.activated.connect(self.__on_activate_parent)
    widget.setWindowIcon(icon_loader.from_description(desc).get(desc.icon))
    widget.setCaption(node.title)
    self.signal_manager()._update()
    return widget
