sirochild commited on
Commit
513d5d7
·
verified ·
1 Parent(s): 810cc3d

Upload 2 files

Browse files
Files changed (2) hide show
  1. main_app.py +36 -12
  2. streamlit_styles.css +2 -12
main_app.py CHANGED
@@ -998,18 +998,34 @@ def update_background(scene_manager: SceneManager, theme: str):
998
  try:
999
  logger.info(f"背景更新(ガード句なし)開始 - テーマ: {theme}")
1000
  css_dict = {
1001
- "default":"background-image: url('https://huggingface.co/spaces/sirochild/mari-chat-3/resolve/main/static/ribinngu-hiru.jpg');",
1002
- "room_night":"background-image: url('https://huggingface.co/spaces/sirochild/mari-chat-3/resolve/main/static/ribinngu-yoru-on.jpg');",
1003
- "beach_sunset":"background-image: url('https://huggingface.co/spaces/sirochild/mari-chat-3/resolve/main/static/sunahama-hiru.jpg');",
1004
- "festival_night":"background-image: url('https://huggingface.co/spaces/sirochild/mari-chat-3/resolve/main/static/maturi-yoru.jpg');",
1005
- "shrine_day":"background-image: url('https://huggingface.co/spaces/sirochild/mari-chat-3/resolve/main/static/jinnjya-hiru.jpg');",
1006
- "cafe_afternoon":"background-image: url('https://huggingface.co/spaces/sirochild/mari-chat-3/resolve/main/static/kissa-hiru.jpg');",
1007
- "art_museum_night":"background-image: url('https://huggingface.co/spaces/sirochild/mari-chat-3/resolve/main/static/bijyutukann-yoru.jpg');",
1008
- }
 
 
 
 
1009
  css = f"""
1010
  <style>
1011
- .stApp {{
1012
- {css_dict.get(theme, css_dict['default'])}
 
 
 
 
 
 
 
 
 
 
 
 
1013
  background-size: cover !important;
1014
  background-position: center !important;
1015
  background-attachment: fixed !important;
@@ -1017,9 +1033,17 @@ def update_background(scene_manager: SceneManager, theme: str):
1017
  min-height: 100vh !important;
1018
  }}
1019
 
 
1020
  html, body {{
1021
- background: none !important;
1022
- }}
 
 
 
 
 
 
 
1023
  </style>
1024
  """
1025
  st.markdown(css, unsafe_allow_html=True)
 
998
  try:
999
  logger.info(f"背景更新(ガード句なし)開始 - テーマ: {theme}")
1000
  css_dict = {
1001
+ "default": "background-image: url('https://huggingface.co/spaces/sirochild/mari-chat-3/resolve/main/static/ribinngu-hiru.jpg');",
1002
+ "room_night": "background-image: url('https://huggingface.co/spaces/sirochild/mari-chat-3/resolve/main/static/ribinngu-yoru-on.jpg');",
1003
+ "beach_sunset": "background-image: url('https://huggingface.co/spaces/sirochild/mari-chat-3/resolve/main/static/sunahama-hiru.jpg');",
1004
+ "festival_night": "background-image: url('https://huggingface.co/spaces/sirochild/mari-chat-3/resolve/main/static/maturi-yoru.jpg');",
1005
+ "shrine_day": "background-image: url('https://huggingface.co/spaces/sirochild/mari-chat-3/resolve/main/static/jinnjya-hiru.jpg');",
1006
+ "cafe_afternoon": "background-image: url('https://huggingface.co/spaces/sirochild/mari-chat-3/resolve/main/static/kissa-hiru.jpg');",
1007
+ "art_museum_night": "background-image: url('https://huggingface.co/spaces/sirochild/mari-chat-3/resolve/main/static/bijyutukann-yoru.jpg');",
1008
+ }
1009
+
1010
+ # デバッグ用:使用する背景画像URLをログ出力
1011
+ selected_bg = css_dict.get(theme, css_dict['default'])
1012
+ logger.info(f"背景画像設定: {selected_bg}")
1013
  css = f"""
1014
  <style>
1015
+ /* 背景画像を確実に適用するための強力なセレクタ - 優先度を最大化 */
1016
+ .stApp.stApp.stApp {{
1017
+ {selected_bg}
1018
+ background-size: cover !important;
1019
+ background-position: center !important;
1020
+ background-attachment: fixed !important;
1021
+ background-repeat: no-repeat !important;
1022
+ min-height: 100vh !important;
1023
+ }}
1024
+
1025
+ /* フォールバック用 - より広範囲に適用 */
1026
+ .stApp > div:first-child,
1027
+ [data-testid="stAppViewContainer"] {{
1028
+ {selected_bg}
1029
  background-size: cover !important;
1030
  background-position: center !important;
1031
  background-attachment: fixed !important;
 
1033
  min-height: 100vh !important;
1034
  }}
1035
 
1036
+ /* bodyとhtmlは透過に */
1037
  html, body {{
1038
+ background: none !important;
1039
+ }}
1040
+
1041
+ /* 他の要素は透過にして背景を見せる */
1042
+ [data-testid="stAppViewContainer"] > section,
1043
+ [data-testid="stAppViewContainer"] > section > div.block-container,
1044
+ .main .block-container {{
1045
+ background: transparent !important;
1046
+ }}
1047
  </style>
1048
  """
1049
  st.markdown(css, unsafe_allow_html=True)
streamlit_styles.css CHANGED
@@ -41,20 +41,10 @@ body {
41
  background: none !important;
42
  }
43
 
44
- /* テーマごとに背景画像を切り替える */
45
-
46
- /* 共通背景設定 */
47
- body[class^="theme-"] {
48
- background-size: cover !important;
49
- background-position: center !important;
50
- background-attachment: fixed !important;
51
- background-repeat: no-repeat !important;
52
- transition: background-image 1.5s ease-in-out;
53
- min-height: 100vh;
54
- }
55
 
56
  /* Streamlit内部背景透過で下の背景を見せる */
57
- .stApp,
58
  [data-testid="stAppViewContainer"] > section,
59
  [data-testid="stAppViewContainer"] > section > div.block-container,
60
  .main .block-container {
 
41
  background: none !important;
42
  }
43
 
44
+ /* 背景画像は動的にJavaScriptで設定されるため、静的な設定は削除 */
 
 
 
 
 
 
 
 
 
 
45
 
46
  /* Streamlit内部背景透過で下の背景を見せる */
47
+ /* .stAppは動的に背景が設定されるため、透過設定を削除 */
48
  [data-testid="stAppViewContainer"] > section,
49
  [data-testid="stAppViewContainer"] > section > div.block-container,
50
  .main .block-container {