soojeongcrystal commited on
Commit
816379e
ยท
verified ยท
1 Parent(s): 0d93b0d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -41
app.py CHANGED
@@ -126,42 +126,35 @@ if st.session_state.page == "๋„๋ฉ”์ธ ์„ค์ •":
126
  # ------------------------------
127
  # PAGE 2. ์—…๋ฌด ๋ฐœ์‚ฐ
128
  # ------------------------------
129
- elif st.session_state.page == "์—…๋ฌด ๋ฐœ์‚ฐ":
130
  st.title("2๏ธโƒฃ ์—…๋ฌด ์ž์œ  ๋ฐœ์‚ฐ")
131
  st.markdown("""
132
  ๊ฐ ๋„๋ฉ”์ธ๋ณ„๋กœ ํŒ€์—์„œ ์‹ค์ œ ํ•˜๊ณ  ์žˆ๋Š” ์ผ์„ ๊ฐ€๋Šฅํ•œ ํ•œ ๋งŽ์ด ์ ์–ด๋ณด์„ธ์š”.
133
  ํ˜•์‹์€ ์ž์œ ๋กญ์Šต๋‹ˆ๋‹ค. ๋‚˜์ค‘์— ๋ฌถ๊ณ  ์ •๋ฆฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
134
  """)
135
-
136
- unique_domains = list(dict.fromkeys(st.session_state.domains))
137
- if "๊ธฐํƒ€" not in unique_domains:
138
- unique_domains.append("๊ธฐํƒ€")
139
-
140
- for d in unique_domains:
141
- safe_key = f"tasks_{d}".replace(" ", "_").replace("/", "_")
142
  st.subheader(f"๐Ÿ“‚ {d}")
143
- text = st.text_area(
144
  f"{d} ๋„๋ฉ”์ธ์˜ ์—…๋ฌด๋“ค",
145
- key=safe_key,
146
  height=150,
147
- placeholder="์˜ˆ: ๋ฆฌ๋”์‹ญ ์ง„๋‹จ ๋ฆฌํฌํŠธ ์ž‘์„ฑ\n์กฐ์ง๋ฌธํ™” ๊ต์œก ๊ธฐํš\n๋ฐ์ดํ„ฐ ์ •๋ฆฌ ์ž๋™ํ™” ๋“ฑ",
148
  )
149
- if text:
150
- st.session_state.grouped_tasks[d] = [t.strip() for t in text.split("\n") if t.strip()]
151
-
 
152
  if st.button("โžก๏ธ ๋‹ค์Œ: ๊ทธ๋ฃน ์กฐ์ •"):
153
  goto("๊ทธ๋ฃน ์กฐ์ •")
154
 
155
- from streamlit_dnd_list import dnd_list
156
- import json
157
 
158
  # ------------------------------
159
- # PAGE 3. ๊ทธ๋ฃน ์กฐ์ • (4์—ด, ๋„๋ฉ”์ธ ๊ฐ„ ์ด๋™ + ์‹œ๊ฐ ๊ตฌ๋ถ„)
160
  # ------------------------------
161
  elif st.session_state.page == "๊ทธ๋ฃน ์กฐ์ •":
162
  st.title("3๏ธโƒฃ ์—…๋ฌด ๊ทธ๋ฃน ์ •๋ฆฌํ•˜๊ธฐ")
163
  st.markdown("""
164
- ๊ฐ ๋„๋ฉ”์ธ๋ณ„๋กœ ์ •๋ฆฌ๋œ ์—…๋ฌด๋ฅผ ์‹œ๊ฐ์ ์œผ๋กœ ๊ด€๋ฆฌํ•˜์„ธ์š”.
165
  - **๋“œ๋ž˜๊ทธ ์•ค ๋“œ๋กญ**์œผ๋กœ ์ˆœ์„œ๋ฅผ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
166
  - **๐Ÿ—‘ ๋ฒ„ํŠผ**์œผ๋กœ ์‚ญ์ œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
167
  - **โ†’ ์„ ํƒ๋ฐ•์Šค**๋ฅผ ํ†ตํ•ด ๋‹ค๋ฅธ ๋„๋ฉ”์ธ์œผ๋กœ ์ด๋™ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
@@ -169,18 +162,16 @@ elif st.session_state.page == "๊ทธ๋ฃน ์กฐ์ •":
169
  """)
170
 
171
  st.divider()
172
-
173
- # ํ˜„์žฌ ์ €์žฅ๋œ ๋„๋ฉ”์ธ ๋ฐ ์—…๋ฌด ๋ถˆ๋Ÿฌ์˜ค๊ธฐ
174
  domains = st.session_state.domains + ["๊ธฐํƒ€"]
175
  updated_grouped = {
176
  d: list(st.session_state.grouped_tasks.get(d, [])) for d in domains
177
  }
178
 
179
- # ๋„๋ฉ”์ธ๋ณ„ ํŒŒ์Šคํ…”ํ†ค ์ƒ‰์ƒ (์‹œ๊ฐ ๊ตฌ๋ถ„)
180
  palette = ["#E3F2FD", "#E8F5E9", "#FFF8E1", "#FCE4EC", "#E0F7FA"]
181
  domain_colors = {d: palette[i % len(palette)] for i, d in enumerate(domains)}
182
 
183
- # CSS ์Šคํƒ€์ผ
184
  st.markdown("""
185
  <style>
186
  .task-card {
@@ -190,23 +181,15 @@ elif st.session_state.page == "๊ทธ๋ฃน ์กฐ์ •":
190
  padding: 6px 10px;
191
  margin-bottom: 6px;
192
  font-size: 14px;
193
- box-shadow: 0 1px 2px rgba(0,0,0,0.05);
194
  }
195
  .domain-box {
196
  border-radius: 10px;
197
  padding: 10px;
198
  margin: 4px;
199
  }
200
- .domain-header {
201
- text-align: center;
202
- font-weight: 600;
203
- font-size: 16px;
204
- margin-bottom: 8px;
205
- }
206
  </style>
207
  """, unsafe_allow_html=True)
208
 
209
- # ๋„๋ฉ”์ธ๋ณ„ ์—ด ๊ตฌ์„ฑ
210
  cols = st.columns(len(domains))
211
  for i, d in enumerate(domains):
212
  with cols[i]:
@@ -215,22 +198,20 @@ elif st.session_state.page == "๊ทธ๋ฃน ์กฐ์ •":
215
  f"<div class='domain-box' style='background-color:{bg_color};'>",
216
  unsafe_allow_html=True,
217
  )
218
- st.markdown(f"<div class='domain-header'>๐Ÿ“ฆ {d}</div>", unsafe_allow_html=True)
219
 
220
  tasks = updated_grouped.get(d, [])
221
  new_task_list = []
222
 
223
- # --- ๋“œ๋ž˜๊ทธ ์ •๋ ฌ ---
224
  sorted_tasks = sort_items(tasks, direction="vertical", key=f"sort_{d}")
225
 
226
- # --- ์—…๋ฌด ํ‘œ์‹œ + ์‚ญ์ œ + ์ด๋™ ---
227
  for t in sorted_tasks:
228
  c1, c2, c3 = st.columns([4, 1, 1])
229
  with c1:
230
  st.markdown(f"<div class='task-card'>{t}</div>", unsafe_allow_html=True)
231
  with c2:
232
  if st.button("๐Ÿ—‘", key=f"del_{d}_{t}"):
233
- # ์‚ญ์ œ: ํ•ด๋‹น ํ•ญ๋ชฉ ์ œ๊ฑฐํ•˜๊ณ  rerun
234
  st.session_state.grouped_tasks[d] = [
235
  x for x in sorted_tasks if x != t
236
  ]
@@ -242,16 +223,14 @@ elif st.session_state.page == "๊ทธ๋ฃน ์กฐ์ •":
242
  key=f"move_{d}_{t}",
243
  )
244
  if move_target != "(์ด๋™)":
245
- # ๋„๋ฉ”์ธ ๊ฐ„ ์ด๋™
246
  st.session_state.grouped_tasks.setdefault(move_target, []).append(t)
247
  st.session_state.grouped_tasks[d] = [
248
  x for x in sorted_tasks if x != t
249
  ]
250
  st.rerun()
251
-
252
  new_task_list.append(t)
253
 
254
- # --- ์ƒˆ ์—…๋ฌด ์ถ”๊ฐ€ ---
255
  new_task = st.text_input(f"{d} ์ƒˆ ์—…๋ฌด", key=f"add_{i}")
256
  if st.button(f"โž• ์ถ”๊ฐ€ ({d})", key=f"btn_add_{i}") and new_task.strip():
257
  new_task_list.append(new_task.strip())
@@ -259,13 +238,10 @@ elif st.session_state.page == "๊ทธ๋ฃน ์กฐ์ •":
259
  st.rerun()
260
 
261
  updated_grouped[d] = new_task_list
262
-
263
  st.markdown("</div>", unsafe_allow_html=True)
264
 
265
- # ์—…๋ฐ์ดํŠธ ๋ฐ˜์˜
266
  st.session_state.grouped_tasks = updated_grouped
267
 
268
- # --- ํ•˜๋‹จ ์ด๋™ ๋ฒ„ํŠผ ---
269
  st.divider()
270
  c1, c2 = st.columns(2)
271
  if c1.button("โฌ…๏ธ ์ด์ „: ์—…๋ฌด ๋ฐœ์‚ฐ ๋‹ค์‹œ๋ณด๊ธฐ"):
@@ -273,7 +249,6 @@ elif st.session_state.page == "๊ทธ๋ฃน ์กฐ์ •":
273
  if c2.button("โžก๏ธ ๋‹ค์Œ: ์˜์กด์„ฑ ํŒ๋‹จ"):
274
  goto("์˜์กด์„ฑ ํŒ๋‹จ")
275
 
276
-
277
  # ------------------------------
278
  # PAGE 4. ์˜์กด์„ฑ ํŒ๋‹จ
279
  # ------------------------------
 
126
  # ------------------------------
127
  # PAGE 2. ์—…๋ฌด ๋ฐœ์‚ฐ
128
  # ------------------------------
129
+ if st.session_state.page == "์—…๋ฌด ๋ฐœ์‚ฐ":
130
  st.title("2๏ธโƒฃ ์—…๋ฌด ์ž์œ  ๋ฐœ์‚ฐ")
131
  st.markdown("""
132
  ๊ฐ ๋„๋ฉ”์ธ๋ณ„๋กœ ํŒ€์—์„œ ์‹ค์ œ ํ•˜๊ณ  ์žˆ๋Š” ์ผ์„ ๊ฐ€๋Šฅํ•œ ํ•œ ๋งŽ์ด ์ ์–ด๋ณด์„ธ์š”.
133
  ํ˜•์‹์€ ์ž์œ ๋กญ์Šต๋‹ˆ๋‹ค. ๋‚˜์ค‘์— ๋ฌถ๊ณ  ์ •๋ฆฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
134
  """)
135
+ for d in st.session_state.domains + ["๊ธฐํƒ€"]:
 
 
 
 
 
 
136
  st.subheader(f"๐Ÿ“‚ {d}")
137
+ task_text = st.text_area(
138
  f"{d} ๋„๋ฉ”์ธ์˜ ์—…๋ฌด๋“ค",
139
+ key=f"tasks_{d}",
140
  height=150,
141
+ placeholder="์˜ˆ: ๋ฆฌ๋”์‹ญ ์ง„๋‹จ ๊ฒฐ๊ณผ ๋ฆฌํฌํŠธ ์ž‘์„ฑ\n์กฐ์ง๋ฌธํ™” ๊ต์œก ๊ธฐํš\n๋ฐ์ดํ„ฐ ์ •๋ฆฌ ์ž๋™ํ™” ๋“ฑ"
142
  )
143
+ if task_text:
144
+ st.session_state.grouped_tasks[d] = [
145
+ t.strip() for t in task_text.split("\n") if t.strip()
146
+ ]
147
  if st.button("โžก๏ธ ๋‹ค์Œ: ๊ทธ๋ฃน ์กฐ์ •"):
148
  goto("๊ทธ๋ฃน ์กฐ์ •")
149
 
 
 
150
 
151
  # ------------------------------
152
+ # PAGE 3. ๊ทธ๋ฃน ์กฐ์ •
153
  # ------------------------------
154
  elif st.session_state.page == "๊ทธ๋ฃน ์กฐ์ •":
155
  st.title("3๏ธโƒฃ ์—…๋ฌด ๊ทธ๋ฃน ์ •๋ฆฌํ•˜๊ธฐ")
156
  st.markdown("""
157
+ ๊ฐ ๋„๋ฉ”์ธ๋ณ„๋กœ ์ •๋ฆฌ๋œ ์—…๋ฌด๋ฅผ ๊ด€๋ฆฌํ•˜์„ธ์š”.
158
  - **๋“œ๋ž˜๊ทธ ์•ค ๋“œ๋กญ**์œผ๋กœ ์ˆœ์„œ๋ฅผ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
159
  - **๐Ÿ—‘ ๋ฒ„ํŠผ**์œผ๋กœ ์‚ญ์ œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
160
  - **โ†’ ์„ ํƒ๋ฐ•์Šค**๋ฅผ ํ†ตํ•ด ๋‹ค๋ฅธ ๋„๋ฉ”์ธ์œผ๋กœ ์ด๋™ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
 
162
  """)
163
 
164
  st.divider()
 
 
165
  domains = st.session_state.domains + ["๊ธฐํƒ€"]
166
  updated_grouped = {
167
  d: list(st.session_state.grouped_tasks.get(d, [])) for d in domains
168
  }
169
 
170
+ # ์ƒ‰์ƒ ์ •์˜
171
  palette = ["#E3F2FD", "#E8F5E9", "#FFF8E1", "#FCE4EC", "#E0F7FA"]
172
  domain_colors = {d: palette[i % len(palette)] for i, d in enumerate(domains)}
173
 
174
+ # ์Šคํƒ€์ผ
175
  st.markdown("""
176
  <style>
177
  .task-card {
 
181
  padding: 6px 10px;
182
  margin-bottom: 6px;
183
  font-size: 14px;
 
184
  }
185
  .domain-box {
186
  border-radius: 10px;
187
  padding: 10px;
188
  margin: 4px;
189
  }
 
 
 
 
 
 
190
  </style>
191
  """, unsafe_allow_html=True)
192
 
 
193
  cols = st.columns(len(domains))
194
  for i, d in enumerate(domains):
195
  with cols[i]:
 
198
  f"<div class='domain-box' style='background-color:{bg_color};'>",
199
  unsafe_allow_html=True,
200
  )
201
+ st.markdown(f"### ๐Ÿ“ฆ {d}")
202
 
203
  tasks = updated_grouped.get(d, [])
204
  new_task_list = []
205
 
206
+ # ์ •๋ ฌ
207
  sorted_tasks = sort_items(tasks, direction="vertical", key=f"sort_{d}")
208
 
 
209
  for t in sorted_tasks:
210
  c1, c2, c3 = st.columns([4, 1, 1])
211
  with c1:
212
  st.markdown(f"<div class='task-card'>{t}</div>", unsafe_allow_html=True)
213
  with c2:
214
  if st.button("๐Ÿ—‘", key=f"del_{d}_{t}"):
 
215
  st.session_state.grouped_tasks[d] = [
216
  x for x in sorted_tasks if x != t
217
  ]
 
223
  key=f"move_{d}_{t}",
224
  )
225
  if move_target != "(์ด๋™)":
 
226
  st.session_state.grouped_tasks.setdefault(move_target, []).append(t)
227
  st.session_state.grouped_tasks[d] = [
228
  x for x in sorted_tasks if x != t
229
  ]
230
  st.rerun()
 
231
  new_task_list.append(t)
232
 
233
+ # ์ถ”๊ฐ€
234
  new_task = st.text_input(f"{d} ์ƒˆ ์—…๋ฌด", key=f"add_{i}")
235
  if st.button(f"โž• ์ถ”๊ฐ€ ({d})", key=f"btn_add_{i}") and new_task.strip():
236
  new_task_list.append(new_task.strip())
 
238
  st.rerun()
239
 
240
  updated_grouped[d] = new_task_list
 
241
  st.markdown("</div>", unsafe_allow_html=True)
242
 
 
243
  st.session_state.grouped_tasks = updated_grouped
244
 
 
245
  st.divider()
246
  c1, c2 = st.columns(2)
247
  if c1.button("โฌ…๏ธ ์ด์ „: ์—…๋ฌด ๋ฐœ์‚ฐ ๋‹ค์‹œ๋ณด๊ธฐ"):
 
249
  if c2.button("โžก๏ธ ๋‹ค์Œ: ์˜์กด์„ฑ ํŒ๋‹จ"):
250
  goto("์˜์กด์„ฑ ํŒ๋‹จ")
251
 
 
252
  # ------------------------------
253
  # PAGE 4. ์˜์กด์„ฑ ํŒ๋‹จ
254
  # ------------------------------