JAMESPARK3 commited on
Commit
897aefa
Β·
verified Β·
1 Parent(s): 4596fb7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -14
app.py CHANGED
@@ -431,7 +431,7 @@ def show_weather_info(data):
431
  st.markdown(f'''
432
  <div class="time-container">
433
  <div style="text-align: center; margin-bottom: 0.5rem; font-size: 6em; font-weight: bold; color: black;">
434
- {temp}{precip_mark} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {tomorrow_morning_weather}
435
  </div>
436
  <span class="date-text">{formatted_date}</span>
437
  </div>
@@ -462,10 +462,14 @@ def show_weather_info(data):
462
  components.html(clock_html, height=300)
463
 
464
  # API ν…ŒμŠ€νŠΈ λ²„νŠΌ
465
- col1, col2, col3 = st.columns([1, 1, 2])
 
466
  with col1:
467
- st.button("μ‹œκ°„λŒ€λ³„ μ˜¨λ„ 보기", on_click=lambda: st.session_state.update({'current_section': 'temperature'}))
 
468
  with col2:
 
 
469
  if st.button("API 응닡 체크"):
470
  new_data = get_weather_data()
471
  if new_data:
@@ -473,7 +477,7 @@ def show_weather_info(data):
473
  st.session_state.weather_data = new_data
474
  st.session_state.last_api_call = datetime.utcnow().timestamp()
475
  st.rerun()
476
- with col3:
477
  network_ok = check_network_status()
478
  if not network_ok:
479
  status_color = "red"
@@ -517,18 +521,18 @@ def show_weather_info(data):
517
  weather_descriptions.append(description)
518
 
519
  # 날씨 예보 생성 및 ν‘œμ‹œ
520
- if 'weather_forecast' not in st.session_state:
521
- forecast_data_str = "\n".join([
522
- f"[{f['FCST_DT'][:4]}λ…„ {f['FCST_DT'][4:6]}μ›” {f['FCST_DT'][6:8]}일 {f['FCST_DT'][8:10]}μ‹œ] {temp}도, {description}"
523
- for f, time, temp, description in zip(forecast_data, times, temps, weather_descriptions)
524
- ])
525
-
526
- current_time_str = current_time.strftime('%Hμ‹œ %MλΆ„')
527
- st.session_state.weather_forecast = get_weather_forecast(forecast_data_str, current_time_str)
528
 
529
  # μ €μž₯된 날씨 예보 ν‘œμ‹œ
530
  st.markdown(f'''
531
- <div class="scroll-container">
532
  <div class="scroll-text">{st.session_state.weather_forecast}</div>
533
  </div>
534
  ''', unsafe_allow_html=True)
@@ -831,7 +835,9 @@ def main():
831
  st.session_state.current_section = 'weather'
832
  st.session_state.last_api_call = 0
833
  st.session_state.weather_data = None
834
- st.session_state.api_failed = False # api_failed μ΄ˆκΈ°ν™” μΆ”κ°€
 
 
835
 
836
  # ν˜„μž¬ μ‹œκ°„μ„ μ„œμšΈ μ‹œκ°„μœΌλ‘œ κ°€μ Έμ˜΅λ‹ˆλ‹€.
837
  current_time = datetime.utcnow() + timedelta(hours=9)
 
431
  st.markdown(f'''
432
  <div class="time-container">
433
  <div style="text-align: center; margin-bottom: 0.5rem; font-size: 6em; font-weight: bold; color: black;">
434
+ {temp}{precip_mark} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {tomorrow_morning_weather}
435
  </div>
436
  <span class="date-text">{formatted_date}</span>
437
  </div>
 
462
  components.html(clock_html, height=300)
463
 
464
  # API ν…ŒμŠ€νŠΈ λ²„νŠΌ
465
+ # show_weather_info() ν•¨μˆ˜μ˜ λ²„νŠΌ λΆ€λΆ„ μˆ˜μ •
466
+ col1, col2, col3, col4 = st.columns([1, 1, 1, 2])
467
  with col1:
468
+ if st.button("날씨 예보 슀크둀", key="toggle_scroll"):
469
+ st.session_state.scroll_visible = not st.session_state.scroll_visible
470
  with col2:
471
+ st.button("μ‹œκ°„λŒ€λ³„ μ˜¨λ„ 보기", on_click=lambda: st.session_state.update({'current_section': 'temperature'}))
472
+ with col3:
473
  if st.button("API 응닡 체크"):
474
  new_data = get_weather_data()
475
  if new_data:
 
477
  st.session_state.weather_data = new_data
478
  st.session_state.last_api_call = datetime.utcnow().timestamp()
479
  st.rerun()
480
+ with col4:
481
  network_ok = check_network_status()
482
  if not network_ok:
483
  status_color = "red"
 
521
  weather_descriptions.append(description)
522
 
523
  # 날씨 예보 생성 및 ν‘œμ‹œ
524
+ background_color = get_background_color(data['PM10'])
525
+ scroll_style = """
526
+ background-color: rgba(255, 255, 255, 0.9);
527
+ color: #333;
528
+ """ if st.session_state.scroll_visible else f"""
529
+ background-color: {background_color};
530
+ color: {background_color};
531
+ """
532
 
533
  # μ €μž₯된 날씨 예보 ν‘œμ‹œ
534
  st.markdown(f'''
535
+ <div class="scroll-container" style="{scroll_style}">
536
  <div class="scroll-text">{st.session_state.weather_forecast}</div>
537
  </div>
538
  ''', unsafe_allow_html=True)
 
835
  st.session_state.current_section = 'weather'
836
  st.session_state.last_api_call = 0
837
  st.session_state.weather_data = None
838
+ st.session_state.api_failed = False
839
+ st.session_state.scroll_visible = False
840
+ st.session_state.weather_forecast = "" # weather_forecast μ΄ˆκΈ°ν™” μΆ”κ°€
841
 
842
  # ν˜„μž¬ μ‹œκ°„μ„ μ„œμšΈ μ‹œκ°„μœΌλ‘œ κ°€μ Έμ˜΅λ‹ˆλ‹€.
843
  current_time = datetime.utcnow() + timedelta(hours=9)