Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Picker - format settings #394

Merged
merged 3 commits into from
Apr 10, 2024

Conversation

bmingles
Copy link
Contributor

@bmingles bmingles commented Mar 28, 2024

  • Update DHC packages to ^0.72.0
  • Passing formatter settings from Redux store to Picker component

Testing
This shows pickers that use number + date formats. Changing format settings will update selected item text + item labels real time.

import deephaven.ui as ui
from deephaven.ui import use_state
from deephaven import time_table
import datetime
 
column_types = time_table("PT2S", start_time=datetime.datetime.now() - datetime.timedelta(seconds=2000)).update([
    "Int=new Integer(i)",
    "Double=new Double(i+i/10)",
])

@ui.component
def picker():
    value, set_value = use_state(1000)
    value2, set_value2 = use_state(1001)
    value3, set_value3 = use_state()

    print("Test", value)

    # Picker for selecting values
    pick = ui.picker(
        column_types,
        key_column="Int",
        label_column="Int",
        label="Int",
        on_selection_change=set_value,
        selected_key=value
    )

    pick2 = ui.picker(
        column_types,
        key_column="Double",
        label_column="Double",
        label="Double",
        on_selection_change=set_value2,
        selected_key=value2,
    )

    pick3 = ui.picker(
        column_types,
        key_column="Timestamp",
        label_column="Timestamp",
        label="Timestamp",
        on_selection_change=set_value3,
        selected_key=value3,
    )

    # Display picker and output in a flex column
    return ui.flex(
        pick,
        ui.text(value, key="text1"),
        pick2,
        ui.text(value2, key="text2"),
        pick3,
        ui.text(value3, key="text3"),
        direction="column",
        margin=10,
        gap=10,
    )

picker_column_types = picker()

resolves #393

@bmingles bmingles force-pushed the 393-picker-format-settings branch 2 times, most recently from 7afc5f3 to c115537 Compare April 3, 2024 17:48
@bmingles bmingles force-pushed the 393-picker-format-settings branch from c115537 to c081b6d Compare April 4, 2024 19:03
@bmingles bmingles marked this pull request as ready for review April 4, 2024 19:12
@bmingles bmingles requested a review from mofojed April 4, 2024 19:28
@bmingles bmingles merged commit f9a0e34 into deephaven:main Apr 10, 2024
18 checks passed
@bmingles bmingles deleted the 393-picker-format-settings branch April 10, 2024 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Picker - use format settings from redux store
2 participants