Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ListView + Picker - Item icon support (#1959)
This example shows both basic and table data sources. ```python import deephaven.ui as ui @ui.component def ui_list_view(): value, set_value = ui.use_state(["Text 2"]) text = ui.text("Selection: " + ", ".join(map(str, value)), grid_column="span 2") # list_view with text children lv = ui.list_view( "Text 1", "Text 2", "Text 3", # min_height=1, aria_label="List View", on_change=set_value, selected_keys=value, ) # list_view with item children lv2 = ui.list_view( ui.item("Item 1", key="Text 1"), ui.item("Item 2", key="Text 2"), ui.item("Item 3", key="Text 3"), aria_label="List View 2", on_change=set_value, selected_keys=value, ) return ui.grid( text, lv, lv2, columns="repeat(2, 1fr)", rows="min-content", height="100%" ) lv = ui_list_view() #################################### import deephaven.ui as ui from deephaven import time_table import datetime icon_names = ['vsAccount'] # Ticking table with initial row count of 200 that adds a row every second initial_row_count=2000 columns = [ "Id=new Integer(i)", "Display=new String(`Display `+i)", "Description=new String(`Description `+i)", "Icon=(String) icon_names[0]" ] # column_types_ticking = time_table("PT1S", start_time=datetime.datetime.now() - datetime.timedelta(seconds=initial_row_count)).update([ # columns # ) column_types = empty_table(initial_row_count).update(columns) @ui.component def labeled_lv(label, *args, **kwargs): return ui.flex( ui.text(label), ui.list_view( *args, **kwargs ), direction="column", flex=1, min_width=0, ) @ui.component def ui_list_view_table(): value, set_value = ui.use_state([2, 4, 5]) lv = labeled_lv( "Compact", column_types, max_height=5000, density="compact", key_column="Id", label_column="Display", icon_column="Icon", aria_label="List View", on_change=set_value, selected_keys=value, ) lv2 = labeled_lv( "Regular", column_types, max_height=5000, density="regular", key_column="Id", label_column="Display", icon_column="Icon", aria_label="List View 2", on_change=set_value, selected_keys=value, ) lv3 = labeled_lv( "Spacious", column_types, max_height=5000, density="spacious", key_column="Id", label_column="Display", icon_column="Icon", aria_label="List View 3", on_change=set_value, selected_keys=value, ) text = ui.text("Selection: " + ", ".join(map(str, value))) return ui.flex( ui.flex( lv, lv2, lv3, direction="row", gap=10, ), text, direction="column", ) lv_table = ui_list_view_table() ``` resolves #1890 --------- Co-authored-by: Don McKenzie <donmckenzie@deephaven.io>
- Loading branch information