<jupyter_start><jupyter_text>ViewListenerA ViewListener listens to all views of a widgets and will report the dimensions. An optional css selector can target specific DOM elements inside the view. The `ViewListener.view_data` dict contains the metadata for each view, and will be updated when a new view gets created, or the DOM elements in one of the views resizes.<jupyter_code>from bqplot_image_gl.viewlistener import ViewListener
import ipywidgets as widgets
slider = widgets.FloatSlider()
slider
vl = ViewListener(widget=slider, css_selector=".ui-slider-handle")<jupyter_output><empty_output><jupyter_text>A viewlistener itself is a DOMWidget, which prints out the `view_data`.<jupyter_code>vl
vl.view_data
slider<jupyter_output><empty_output><jupyter_text>If we modify the width of the slider handle, the `view_data` should be updated.<jupyter_code>%%html
<style type="text/css">
.widget-hslider .ui-slider .ui-slider-handle {
    width: 40px;
}
</style><jupyter_output><empty_output><jupyter_text>Using bqplot<jupyter_code>import bqplot
# simple empty figure
figure = bqplot.Figure()
figure
# listen to the main bqplot canvas
vl_figure = ViewListener(widget=figure, css_selector=".svg-figure > g")
vl_figure<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08520900321543408, 'fraction_numerical': 0.001607717041800643, 'mean_word_length': 6.929936305732484, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '452051', 'license': 'MIT', 'n_tokens_mistral': 394, 'n_tokens_neox': 388, 'n_words': 120, 'path': 'examples/viewlistener.ipynb', 'repo_name': 'glue-viz/bqplot-image-gl', 'size': '1244'}