sterepando commited on
Commit
66c8e2e
·
verified ·
1 Parent(s): baef81c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -10
app.py CHANGED
@@ -30,7 +30,7 @@ html_content = """
30
  margin: 0;
31
  padding: 20px;
32
  user-select: none;
33
- overflow-y: auto;
34
  }
35
 
36
  h1 { margin-bottom: 10px; font-weight: 900; }
@@ -40,6 +40,7 @@ html_content = """
40
  gap: 30px;
41
  flex-wrap: wrap;
42
  justify-content: center;
 
43
  }
44
 
45
  .preview-area {
@@ -760,22 +761,26 @@ html_content = """
760
  """
761
 
762
  def create_app():
763
- # Изолируем HTML через iframe, закодировав в Base64.
764
- # Это решает все конфликты CSS и JS.
765
  encoded_html = base64.b64encode(html_content.encode('utf-8')).decode('utf-8')
766
- iframe_html = f'<iframe src="data:text/html;base64,{encoded_html}" style="width:100%; height:100vh; border:none; display:block;"></iframe>'
767
 
768
- # Стили для самого Gradio контейнера (чтобы убрать отступы и футер)
769
- # Вставляем их через gr.HTML, так как аргумент css= в gr.Blocks может не работать
 
 
 
 
 
 
 
770
  global_css = """
771
  <style>
772
- footer {visibility: hidden !important;}
773
- .gradio-container {padding: 0 !important; margin: 0 !important; max-width: 100% !important;}
774
- #component-0 {height: 100vh !important; border: none !important;}
775
  </style>
776
  """
777
 
778
- # Убрали аргумент css=, чтобы не вызывать ошибку версии
779
  with gr.Blocks(title="Swaga Icon Maker") as demo:
780
  gr.HTML(global_css)
781
  gr.HTML(iframe_html)
 
30
  margin: 0;
31
  padding: 20px;
32
  user-select: none;
33
+ overflow-y: auto; /* Скролл внутри iframe, если контент не влазит */
34
  }
35
 
36
  h1 { margin-bottom: 10px; font-weight: 900; }
 
40
  gap: 30px;
41
  flex-wrap: wrap;
42
  justify-content: center;
43
+ padding-bottom: 50px; /* Отступ снизу для удобства */
44
  }
45
 
46
  .preview-area {
 
761
  """
762
 
763
  def create_app():
764
+ # Кодируем HTML в base64
 
765
  encoded_html = base64.b64encode(html_content.encode('utf-8')).decode('utf-8')
 
766
 
767
+ # КЛЮЧЕВОЕ ИЗМЕНЕНИЕ: position: fixed.
768
+ # Это вырывает iframe из потока документа Gradio, предотвращая бесконечное расширение.
769
+ # top: 0, left: 0, width: 100%, height: 100% заставляет его занять всё окно браузера.
770
+ iframe_html = f'''
771
+ <iframe src="data:text/html;base64,{encoded_html}"
772
+ style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; border: none; z-index: 9999;">
773
+ </iframe>'''
774
+
775
+ # Стили для подавления самого интерфейса Gradio под нашим iframe
776
  global_css = """
777
  <style>
778
+ footer {display: none !important;}
779
+ body {overflow: hidden !important;}
780
+ .gradio-container {min-height: 0 !important; overflow: hidden !important;}
781
  </style>
782
  """
783
 
 
784
  with gr.Blocks(title="Swaga Icon Maker") as demo:
785
  gr.HTML(global_css)
786
  gr.HTML(iframe_html)