trohith89 commited on
Commit
6374d50
·
verified ·
1 Parent(s): 79da4ed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -52,8 +52,16 @@ with left_col:
52
  for i, (btn_label, func_value) in enumerate(predefined_functions.items()):
53
  with cols[i]:
54
  if st.button(btn_label):
55
- st.session_state.func_input = func_value
56
  reset_state()
 
 
 
 
 
 
 
 
57
 
58
  # Gradient Descent Parameters
59
  st.subheader("Gradient Descent Parameters")
 
52
  for i, (btn_label, func_value) in enumerate(predefined_functions.items()):
53
  with cols[i]:
54
  if st.button(btn_label):
55
+ st.session_state['temp_func_input'] = func_value # Store the value temporarily
56
  reset_state()
57
+
58
+ # Sync temp_func_input with the actual func_input
59
+ if 'temp_func_input' in st.session_state:
60
+ func_input = st.text_input("Enter a function of 'x':", st.session_state['temp_func_input'], key="func_input", on_change=reset_state)
61
+ del st.session_state['temp_func_input'] # Clean up temporary variable
62
+ else:
63
+ func_input = st.text_input("Enter a function of 'x':", "x**2 + x", key="func_input", on_change=reset_state)
64
+
65
 
66
  # Gradient Descent Parameters
67
  st.subheader("Gradient Descent Parameters")