def create_widget(self, place, type, file=None, **kwargs):
widget_class = self.widget_types.get(type, self.widget_types['<STR_LIT>'])<EOL>kwargs.update(place=place, type=type)<EOL>try:<EOL><INDENT>element = widget_class(**kwargs)<EOL><DEDENT>except TypeError as e:<EOL><INDENT>message = e.args[<NUM_LIT:0>] if e.args else '<STR_LIT>'<EOL>if (<EOL>'<STR_LIT>' in message or<EOL>'<STR_LIT>' in message<EOL>):<EOL><INDENT>raise WidgetParameterException(<EOL>'<STR_LIT>'<EOL>% (type, message, widget_class._fields)<EOL>)<EOL><DEDENT>raise e<EOL><DEDENT>if file and any(map(callable, element)):<EOL><INDENT>return self._resolve_widget(file, element)<EOL><DEDENT>return element<EOL>
Create a widget object based on given arguments.

If file object is provided, callable arguments will be resolved:
its return value will be used after calling them with file as first
parameter.

All extra `kwargs` parameters will be passed to widget constructor.

:param place: place hint where widget should be shown.
:type place: str
:param type: widget type name as taken from :attr:`widget_types` dict
             keys.
:type type: str
:param file: optional file object for widget attribute resolving
:type type: browsepy.files.Node or None
:returns: widget instance
:rtype: object