JAMESPARK3 commited on
Commit
2b0c8fb
Β·
verified Β·
1 Parent(s): 897aefa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +53 -7
app.py CHANGED
@@ -461,12 +461,59 @@ def show_weather_info(data):
461
  """
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:
@@ -520,14 +567,13 @@ def show_weather_info(data):
520
 
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
  # μ €μž₯된 날씨 예보 ν‘œμ‹œ
 
461
  """
462
  components.html(clock_html, height=300)
463
 
464
+ # 날씨 예보 생성 및 슀크둀 μ»¨ν…Œμ΄λ„ˆ ν‘œμ‹œ
 
465
  col1, col2, col3, col4 = st.columns([1, 1, 1, 2])
466
  with col1:
467
  if st.button("날씨 예보 슀크둀", key="toggle_scroll"):
468
  st.session_state.scroll_visible = not st.session_state.scroll_visible
469
+
470
+ # 날씨 예보 생성
471
+ forecast_data = data['FCST24HOURS']['FCST24HOURS']
472
+ if not isinstance(forecast_data, list):
473
+ forecast_data = [forecast_data]
474
+
475
+ forecast_data_str = "\n".join([
476
+ f"[{f['FCST_DT'][:4]}λ…„ {f['FCST_DT'][4:6]}μ›” {f['FCST_DT'][6:8]}일 {f['FCST_DT'][8:10]}μ‹œ] {f['TEMP']}도, {f['SKY_STTS']}"
477
+ for f in forecast_data
478
+ ])
479
+
480
+ current_time = datetime.utcnow() + timedelta(hours=9)
481
+ current_time_str = current_time.strftime('%Hμ‹œ %MλΆ„')
482
+
483
+ # 날씨 예보 ν…μŠ€νŠΈ 생성
484
+ st.session_state.weather_forecast = get_weather_forecast(forecast_data_str, current_time_str)
485
+
486
+ # 슀크둀 μ»¨ν…Œμ΄λ„ˆ CSS
487
+ background_color = get_background_color(data['PM10'])
488
+ display_style = "block" if st.session_state.scroll_visible else "none"
489
+ scroll_style = f"""
490
+ background-color: rgba(255, 255, 255, 0.9);
491
+ color: #333;
492
+ display: {display_style};
493
+ position: fixed;
494
+ bottom: 20px;
495
+ left: 0;
496
+ width: 100%;
497
+ overflow: hidden;
498
+ padding: 10px 0;
499
+ z-index: 1000;
500
+ """
501
+
502
+ text_style = """
503
+ white-space: nowrap;
504
+ animation: scroll-text 30s linear infinite;
505
+ display: inline-block;
506
+ font-size: 2.5em;
507
+ font-weight: bold;
508
+ """
509
+
510
+ # 슀크둀 μ»¨ν…Œμ΄λ„ˆ ν‘œμ‹œ
511
+ st.markdown(f'''
512
+ <div class="scroll-container" style="{scroll_style}">
513
+ <div class="scroll-text" style="{text_style}">{st.session_state.weather_forecast}</div>
514
+ </div>
515
+ ''', unsafe_allow_html=True)
516
+
517
  with col2:
518
  st.button("μ‹œκ°„λŒ€λ³„ μ˜¨λ„ 보기", on_click=lambda: st.session_state.update({'current_section': 'temperature'}))
519
  with col3:
 
567
 
568
  weather_descriptions.append(description)
569
 
570
+ # 슀크둀 μ»¨ν…Œμ΄λ„ˆ ν‘œμ‹œ
571
  background_color = get_background_color(data['PM10'])
572
+ display_style = "block" if st.session_state.scroll_visible else "none"
573
+ scroll_style = f"""
574
  background-color: rgba(255, 255, 255, 0.9);
575
  color: #333;
576
+ display: {display_style};
 
 
577
  """
578
 
579
  # μ €μž₯된 날씨 예보 ν‘œμ‹œ