Silvia Terragni commited on
Commit
0789e97
1 Parent(s): bca94f8

added suggestions to text input

Browse files
Files changed (1) hide show
  1. text2image.py +18 -1
text2image.py CHANGED
@@ -73,7 +73,24 @@ def app():
73
  """
74
  )
75
 
76
- query = st.text_input("Insert an italian query text here...")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  if query:
78
  with st.spinner("Computing in progress..."):
79
  model = get_model()
 
73
  """
74
  )
75
 
76
+ if 'suggestion' not in st.session_state:
77
+ st.session_state.suggestion = ""
78
+
79
+ def update_query(value=""):
80
+ st.session_state.suggestion = value
81
+
82
+ col1, col2, col3, col4 = st.beta_columns(4)
83
+ with col1:
84
+ st.button('Un gatto', on_click=update_query, kwargs=dict(value='Un gatto'))
85
+ with col2:
86
+ st.button('Due gatti', on_click=update_query, kwargs=dict(value='Due gatti'))
87
+ with col3:
88
+ st.button('Un fiore giallo', on_click=update_query, kwargs=dict(value='Un fiore giallo'))
89
+ with col4:
90
+ st.button('Un fiore blu', on_click=update_query, kwargs=dict(value='Un fiore blu'))
91
+
92
+ query = st.text_input('Insert an italian query text here...', st.session_state.suggestion)
93
+
94
  if query:
95
  with st.spinner("Computing in progress..."):
96
  model = get_model()