将css样式移动到theme文件,减少main.py的代码行数

This commit is contained in:
Your Name 2023-04-01 03:39:43 +08:00
parent 364810983a
commit 639e24fc82
2 changed files with 14 additions and 14 deletions

16
main.py
View File

@ -33,23 +33,11 @@ crazy_fns = get_crazy_functionals()
gr.Chatbot.postprocess = format_io
# 做一些外观色彩上的调整
from theme import adjust_theme
from theme import adjust_theme, advanced_css
set_theme = adjust_theme()
CSS = """
.markdown-body table {
border: 1px solid #ddd;
border-collapse: collapse;
}
.markdown-body th, .markdown-body td {
border: 1px solid #ddd;
padding: 5px;
}
"""
cancel_handles = []
with gr.Blocks(theme=set_theme, analytics_enabled=False, css=CSS) as demo:
with gr.Blocks(theme=set_theme, analytics_enabled=False, css=advanced_css) as demo:
gr.HTML(title_html)
with gr.Row().style(equal_height=True):
with gr.Column(scale=2):

View File

@ -80,3 +80,15 @@ def adjust_theme():
except:
set_theme = None; print('gradio版本较旧, 不能自定义字体和颜色')
return set_theme
advanced_css = """
.markdown-body table {
border: 1px solid #ddd;
border-collapse: collapse;
}
.markdown-body th, .markdown-body td {
border: 1px solid #ddd;
padding: 5px;
}
"""