def test_register_interactive_write_interactive(): test_css = ps.Css(css_string='test styles', name='test name') ps.register_interactive(test_css) stream = StringIO() ps.write_interactive(stream) assert 'test styles' in stream.getvalue() # Add once more, should not be in final output more than once ps.register_interactive(test_css) stream = StringIO() ps.write_interactive(stream) assert stream.getvalue().count('test styles') == 1
def interactive(verbose=True): """ Enables interactive usage of block layout content. """ from IPython.core.display import display, HTML, display_html from pybloqs.static import write_interactive from pybloqs.html import set_id_generator, id_generator_uuid set_id_generator(id_generator_uuid) stream = StringIO() write_interactive(stream) if verbose: stream.write("<div>Interactive mode initialized successfully</div>") # Send the scripts to the frontend display_html(stream.getvalue(), raw=True)