Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -461,12 +461,59 @@ def show_weather_info(data):
|
|
| 461 |
"""
|
| 462 |
components.html(clock_html, height=300)
|
| 463 |
|
| 464 |
-
#
|
| 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 |
-
|
|
|
|
| 526 |
background-color: rgba(255, 255, 255, 0.9);
|
| 527 |
color: #333;
|
| 528 |
-
|
| 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 |
# μ μ₯λ λ μ¨ μ보 νμ
|