-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mike dupont
committed
Sep 17, 2023
1 parent
a41c94e
commit 74aff6b
Showing
2 changed files
with
38 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
from .app_args import get_concept_id,params,app_args | ||
from .columns import col_concept | ||
import streamlit as st | ||
from .modules.streamlitio.selector.list_input import list_input | ||
from .app_args import params,app_args | ||
from .columns import col_concept | ||
|
||
concept_choices = ["python", "streamlit", "clarifai"] # Replace with your actual choices | ||
|
||
def get_concept_id(): | ||
return app_args['concept_id'] | ||
def get_inputs(): | ||
with col_concept: | ||
app_args["concept_id"] = st.text_input( | ||
"Concept ID", | ||
key = "concept_id", | ||
help = "Concept id to search for" , | ||
value = params.get("concept_id","python") | ||
) | ||
return get_concept_id() | ||
|
||
def get_concept(): | ||
# Replace this part with your desired input logic | ||
app_args["mode"] = list_input( | ||
"Select a Concept", | ||
concept_choices, | ||
key="concept-choice", | ||
default_value=params.get("concept_id", "python") | ||
) | ||
|
||
get_concept_id() | ||
|
20 changes: 20 additions & 0 deletions
20
src/introspector/modules/streamlitio/selector/list_input.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import streamlit as st | ||
|
||
def list_input(title, choices, key, default_value): | ||
opt_index = 0 | ||
if default_value in choices: | ||
opt_index = choices.index(default_value) | ||
|
||
selected_choice = st.selectbox( | ||
title, | ||
choices, | ||
key=key, | ||
index=opt_index, | ||
) | ||
|
||
return selected_choice | ||
``` | ||
|
||
Now, you can use this `list_input` function to create list-based inputs. Here's how you can use it for your `get_concept` function: | ||
|
||
```python |