text_extensions_for_pandas/jupyter/widget/span.py
def DataFrameDocumentControlsComponent(widget, span_columns):  # -> ipw.Widget:
    """A widget that exposes controls for rendering spans in various ways."""

    control_widgets = []

    # Branch based on number of span columns in the dataframe

    # If there's only one span column, we just want to choose the tag column from all
    # columns
    if len(span_columns) == 1:
        # Tag dropdown
        tag_values = map(lambda v: (v, ("column_data", v)), widget._df.columns.values)
        tag_dropdown = ipw.Dropdown(
            options=[("None", None), *tag_values],
            description="tag",
            value=widget._tag_display,
        )
        tag_dropdown.observe(widget._update_tag, names="value")
        control_widgets.append(tag_dropdown)

        # Color Mode Dropdown
        color_mode_values = [("By Row", "ROW"), ("By Tag", "TAG")]
        color_dropdown = ipw.Dropdown(
            options=color_mode_values,
            description="color_mode",
            value=widget._color_mode,
        )
        color_dropdown.observe(widget._update_color_mode, names="value")
        control_widgets.append(color_dropdown)

        return ipw.HBox(control_widgets)

    # If there are multiple span columns, add some additional options
    elif len(span_columns) > 1:
        # Tag Dropdown
        tag_values = map(lambda v: (v, ("column_data", v)), widget._df.columns.values)
        tag_dropdown = ipw.Dropdown(
            options=[("None", None), ("Col Headers", ("column_header")), *tag_values],
            description="tag",
            value=widget._tag_display,
        )
        tag_dropdown.observe(widget._update_tag, names="value")
        control_widgets.append(tag_dropdown)

        # Color Mode Dropdown
        color_mode_values = [("By Row", "ROW"), ("By Tag", "TAG")]
        color_dropdown = ipw.Dropdown(
            options=color_mode_values,
            description="color_mode",
            value=widget._color_mode,
        )
        color_dropdown.observe(widget._update_color_mode, names="value")
        control_widgets.append(color_dropdown)

        return ipw.HBox(control_widgets)

    return ipw.HTML("")
A widget that exposes controls for rendering spans in various ways.
A widget that exposes controls for rendering spans in various ways.
A widget that exposes controls for rendering spans in various ways .
def DataFrameDocumentControlsComponent(widget, span_columns):  
    control_widgets = []
    if len(span_columns) == 1:
        tag_values = map(lambda v: (v, ("column_data", v)), widget._df.columns.values)
        tag_dropdown = ipw.Dropdown(
            options=[("None", None), *tag_values],
            description="tag",
            value=widget._tag_display,
        )
        tag_dropdown.observe(widget._update_tag, names="value")
        control_widgets.append(tag_dropdown)
        color_mode_values = [("By Row", "ROW"), ("By Tag", "TAG")]
        color_dropdown = ipw.Dropdown(
            options=color_mode_values,
            description="color_mode",
            value=widget._color_mode,
        )
        color_dropdown.observe(widget._update_color_mode, names="value")
        control_widgets.append(color_dropdown)
        return ipw.HBox(control_widgets)
    elif len(span_columns) > 1:
        tag_values = map(lambda v: (v, ("column_data", v)), widget._df.columns.values)
        tag_dropdown = ipw.Dropdown(
            options=[("None", None), ("Col Headers", ("column_header")), *tag_values],
            description="tag",
            value=widget._tag_display,
        )
        tag_dropdown.observe(widget._update_tag, names="value")
        control_widgets.append(tag_dropdown)
        color_mode_values = [("By Row", "ROW"), ("By Tag", "TAG")]
        color_dropdown = ipw.Dropdown(
            options=color_mode_values,
            description="color_mode",
            value=widget._color_mode,
        )
        color_dropdown.observe(widget._update_color_mode, names="value")
        control_widgets.append(color_dropdown)
        return ipw.HBox(control_widgets)
    return ipw.HTML("")
def DataFrameDocumentControlsComponent ( widget , span_columns ) : control_widgets = [ ] if len ( span_columns ) == 1 : tag_values = map ( lambda v : ( v , ( "column_data" , v ) ) , widget . _df . columns . values ) tag_dropdown = ipw . Dropdown ( options = [ ( "None" , None ) , * tag_values ] , description = "tag" , value = widget . _tag_display , ) tag_dropdown . observe ( widget . _update_tag , names = "value" ) control_widgets . append ( tag_dropdown ) color_mode_values = [ ( "By Row" , "ROW" ) , ( "By Tag" , "TAG" ) ] color_dropdown = ipw . Dropdown ( options = color_mode_values , description = "color_mode" , value = widget . _color_mode , ) color_dropdown . observe ( widget . _update_color_mode , names = "value" ) control_widgets . append ( color_dropdown ) return ipw . HBox ( control_widgets ) elif len ( span_columns ) > 1 : tag_values = map ( lambda v : ( v , ( "column_data" , v ) ) , widget . _df . columns . values ) tag_dropdown = ipw . Dropdown ( options = [ ( "None" , None ) , ( "Col Headers" , ( "column_header" ) ) , * tag_values ] , description = "tag" , value = widget . _tag_display , ) tag_dropdown . observe ( widget . _update_tag , names = "value" ) control_widgets . append ( tag_dropdown ) color_mode_values = [ ( "By Row" , "ROW" ) , ( "By Tag" , "TAG" ) ] color_dropdown = ipw . Dropdown ( options = color_mode_values , description = "color_mode" , value = widget . _color_mode , ) color_dropdown . observe ( widget . _update_color_mode , names = "value" ) control_widgets . append ( color_dropdown ) return ipw . HBox ( control_widgets ) return ipw . HTML ( "" )
A widget that exposes controls for rendering spans in various ways.
A widget that exposes controls for rendering spans in various ways .
# -> ipw.Widget: """A widget that exposes controls for rendering spans in various ways.""" # Branch based on number of span columns in the dataframe # If there's only one span column, we just want to choose the tag column from all # columns # Tag dropdown # Color Mode Dropdown # If there are multiple span columns, add some additional options # Tag Dropdown # Color Mode Dropdown
widget
span_columns