pjgerrits commited on
Commit
7635eb3
1 Parent(s): 2b57c0b

update app with controls

Browse files
Files changed (1) hide show
  1. app.py +28 -19
app.py CHANGED
@@ -54,30 +54,24 @@ def submit_data(age, gender, transport, multi_transport, time_of_day, day_of_wee
54
  cursor.close()
55
  conn.close()
56
 
57
- # Sidebar form inputs
58
- st.sidebar.title("Getting Lost Survey")
59
-
60
- age = st.sidebar.selectbox("Age", ["0-10", "11-20", "21-30", "31-40", "41-50", "51-60", "61-70", "71-80", "81-90", "91-100"])
61
- gender = st.sidebar.radio("Gender", ["M", "F", "O", "PNTS"])
62
- transport = st.sidebar.radio("Mode of Transport", ["Walk", "Car", "Bike", "Train", "Other", "Multi"])
63
-
64
- multi_transport = []
65
- if transport == "Multi":
66
- multi_transport = st.sidebar.multiselect("If Multi, Select Modes Used", ["Walk", "Car", "Bike", "Train", "Other"])
67
-
68
- time_of_day = st.sidebar.selectbox("Time of Day", ["Morning", "Afternoon", "Evening", "Night"])
69
- day_of_week = st.sidebar.selectbox("Day of the Week", ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"])
70
- description = st.sidebar.text_area("Why did you get lost?")
71
-
72
- # Initialize points in session state
73
  if 'points' not in st.session_state:
74
  st.session_state['points'] = {'start': None, 'lost': None, 'end': None}
75
 
76
- # Map interaction
77
- st.title("Select Points on the Map")
78
 
79
  # Selector for point type
80
- point_type = st.radio("Select Point Type to Add", ["start", "lost", "end"])
 
 
 
 
 
 
 
 
 
81
 
82
  # Initialize map
83
  m = folium.Map(location=[51.5074, -0.1278], zoom_start=10, control_scale=True)
@@ -121,6 +115,21 @@ if output and 'last_clicked' in output and output['last_clicked'] is not None:
121
  # Display current points
122
  st.write("Current Points:", st.session_state['points'])
123
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  if st.sidebar.button("Save"):
125
  submit_data(age, gender, transport, multi_transport, time_of_day, day_of_week, description, st.session_state['points'])
126
 
 
54
  cursor.close()
55
  conn.close()
56
 
57
+ # Initialize session state for points
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  if 'points' not in st.session_state:
59
  st.session_state['points'] = {'start': None, 'lost': None, 'end': None}
60
 
61
+ # Sidebar for marker management
62
+ st.sidebar.title("Step 1: Add Markers on the Map")
63
 
64
  # Selector for point type
65
+ point_type = st.sidebar.radio("Select Point Type to Add", ["start", "lost", "end"])
66
+
67
+ # Buttons to clear points
68
+ if st.sidebar.button("Clear All Markers"):
69
+ st.session_state['points'] = {'start': None, 'lost': None, 'end': None}
70
+ st.experimental_rerun()
71
+
72
+ if st.sidebar.button("Clear Selected Marker"):
73
+ st.session_state['points'][point_type] = None
74
+ st.experimental_rerun()
75
 
76
  # Initialize map
77
  m = folium.Map(location=[51.5074, -0.1278], zoom_start=10, control_scale=True)
 
115
  # Display current points
116
  st.write("Current Points:", st.session_state['points'])
117
 
118
+ # Step 2: Survey questions
119
+ st.sidebar.title("Step 2: Fill Out the Survey")
120
+
121
+ age = st.sidebar.selectbox("Age", ["0-10", "11-20", "21-30", "31-40", "41-50", "51-60", "61-70", "71-80", "81-90", "91-100"])
122
+ gender = st.sidebar.radio("Gender", ["M", "F", "O", "PNTS"])
123
+ transport = st.sidebar.radio("Mode of Transport", ["Walk", "Car", "Bike", "Train", "Other", "Multi"])
124
+
125
+ multi_transport = []
126
+ if transport == "Multi":
127
+ multi_transport = st.sidebar.multiselect("If Multi, Select Modes Used", ["Walk", "Car", "Bike", "Train", "Other"])
128
+
129
+ time_of_day = st.sidebar.selectbox("Time of Day", ["Morning", "Afternoon", "Evening", "Night"])
130
+ day_of_week = st.sidebar.selectbox("Day of the Week", ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"])
131
+ description = st.sidebar.text_area("Why did you get lost?")
132
+
133
  if st.sidebar.button("Save"):
134
  submit_data(age, gender, transport, multi_transport, time_of_day, day_of_week, description, st.session_state['points'])
135