Skip to content

Commit

Permalink
feat(streamlit): extend library api method with args parameter for ca…
Browse files Browse the repository at this point in the history
…llback on top of text (#4)

* added args val for callback on top of text
* need key for multiple instances too
  • Loading branch information
norton120 authored Sep 23, 2024
1 parent 8048712 commit aae2fdc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion textcomplete/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
Optional,
TypedDict,
TypeVar,
Tuple,
Union,
)

Expand Down Expand Up @@ -133,6 +134,8 @@ def textcomplete(
stop_enter_propagation: bool = False,
dynamic_width: bool = True,
dropdown_style: str = "",
args: Optional[Tuple] = tuple(),
key: Optional[str] = None,
) -> Optional[TextcompleteResult]:
# Call through to our private component function. Arguments we pass here
# will be sent to the frontend, where they'll be available in an "args"
Expand Down Expand Up @@ -161,10 +164,11 @@ def textcomplete(
strategies=[strategy.to_dict() for strategy in strategies],
dropdown_option=dropdown_option,
stop_enter_propagation=stop_enter_propagation,
key=key,
)

if on_select and result:
on_select(result)
on_select(result, *args)

# We could modify the value returned from the component if we wanted.
# There's no need to do this in our simple example - but it's an option.
Expand Down

0 comments on commit aae2fdc

Please sign in to comment.