def enable_gui(gui, kernel=None):
if gui not in loop_map:<EOL><INDENT>raise ValueError("<STR_LIT>" % gui)<EOL><DEDENT>if kernel is None:<EOL><INDENT>if Application.initialized():<EOL><INDENT>kernel = getattr(Application.instance(), '<STR_LIT>', None)<EOL><DEDENT>if kernel is None:<EOL><INDENT>raise RuntimeError("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT><DEDENT>loop = loop_map[gui]<EOL>if kernel.eventloop is not None and kernel.eventloop is not loop:<EOL><INDENT>raise RuntimeError("<STR_LIT>")<EOL><DEDENT>kernel.eventloop = loop<EOL>
Enable integration with a given GUI