Update app.py
Browse files
app.py
CHANGED
|
@@ -198,12 +198,26 @@ def main_app():
|
|
| 198 |
net_savings = 0
|
| 199 |
max_savings = total_income - total_expense - net_savings
|
| 200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
# Buttons to toggle between setting goal and allocating savings
|
| 202 |
set_goal_button = st.button("Set Saving Goal")
|
| 203 |
allocate_savings_button = st.button("Allocate Saving to Goal")
|
| 204 |
|
| 205 |
-
#
|
| 206 |
if set_goal_button:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
st.subheader("Set Saving Goal")
|
| 208 |
goal_name = st.text_input("Goal Name")
|
| 209 |
target_amount = st.number_input("Target Amount", min_value=0, step=100)
|
|
@@ -225,7 +239,7 @@ def main_app():
|
|
| 225 |
st.error("Please provide valid goal name and target amount.")
|
| 226 |
|
| 227 |
# Allocate Savings Form
|
| 228 |
-
if
|
| 229 |
st.subheader("Allocate Savings to Goals")
|
| 230 |
if not st.session_state["saving_goals"].empty:
|
| 231 |
# Add a dropdown to select a goal
|
|
@@ -279,6 +293,7 @@ def main_app():
|
|
| 279 |
|
| 280 |
|
| 281 |
|
|
|
|
| 282 |
else:
|
| 283 |
st.write("No saving goals set yet.")
|
| 284 |
|
|
|
|
| 198 |
net_savings = 0
|
| 199 |
max_savings = total_income - total_expense - net_savings
|
| 200 |
|
| 201 |
+
# Initialize session state for buttons if not already done
|
| 202 |
+
if "show_set_goal_form" not in st.session_state:
|
| 203 |
+
st.session_state["show_set_goal_form"] = False
|
| 204 |
+
if "show_allocate_savings_form" not in st.session_state:
|
| 205 |
+
st.session_state["show_allocate_savings_form"] = False
|
| 206 |
+
|
| 207 |
# Buttons to toggle between setting goal and allocating savings
|
| 208 |
set_goal_button = st.button("Set Saving Goal")
|
| 209 |
allocate_savings_button = st.button("Allocate Saving to Goal")
|
| 210 |
|
| 211 |
+
# Toggle the display state for each form
|
| 212 |
if set_goal_button:
|
| 213 |
+
st.session_state["show_set_goal_form"] = True
|
| 214 |
+
st.session_state["show_allocate_savings_form"] = False # Hide other form
|
| 215 |
+
if allocate_savings_button:
|
| 216 |
+
st.session_state["show_allocate_savings_form"] = True
|
| 217 |
+
st.session_state["show_set_goal_form"] = False # Hide other form
|
| 218 |
+
|
| 219 |
+
# Set Saving Goal Form
|
| 220 |
+
if st.session_state["show_set_goal_form"]:
|
| 221 |
st.subheader("Set Saving Goal")
|
| 222 |
goal_name = st.text_input("Goal Name")
|
| 223 |
target_amount = st.number_input("Target Amount", min_value=0, step=100)
|
|
|
|
| 239 |
st.error("Please provide valid goal name and target amount.")
|
| 240 |
|
| 241 |
# Allocate Savings Form
|
| 242 |
+
if st.session_state["show_allocate_savings_form"]:
|
| 243 |
st.subheader("Allocate Savings to Goals")
|
| 244 |
if not st.session_state["saving_goals"].empty:
|
| 245 |
# Add a dropdown to select a goal
|
|
|
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
+
|
| 297 |
else:
|
| 298 |
st.write("No saving goals set yet.")
|
| 299 |
|