3v324v23 commited on
Commit
b0dfef4
1 Parent(s): c85923b

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

Browse files
Files changed (2) hide show
  1. main.py +2 -14
  2. theme.py +12 -0
main.py CHANGED
@@ -33,23 +33,11 @@ crazy_fns = get_crazy_functionals()
33
  gr.Chatbot.postprocess = format_io
34
 
35
  # 做一些外观色彩上的调整
36
- from theme import adjust_theme
37
  set_theme = adjust_theme()
38
 
39
- CSS = """
40
- .markdown-body table {
41
- border: 1px solid #ddd;
42
- border-collapse: collapse;
43
- }
44
-
45
- .markdown-body th, .markdown-body td {
46
- border: 1px solid #ddd;
47
- padding: 5px;
48
- }
49
- """
50
-
51
  cancel_handles = []
52
- with gr.Blocks(theme=set_theme, analytics_enabled=False, css=CSS) as demo:
53
  gr.HTML(title_html)
54
  with gr.Row().style(equal_height=True):
55
  with gr.Column(scale=2):
 
33
  gr.Chatbot.postprocess = format_io
34
 
35
  # 做一些外观色彩上的调整
36
+ from theme import adjust_theme, advanced_css
37
  set_theme = adjust_theme()
38
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  cancel_handles = []
40
+ with gr.Blocks(theme=set_theme, analytics_enabled=False, css=advanced_css) as demo:
41
  gr.HTML(title_html)
42
  with gr.Row().style(equal_height=True):
43
  with gr.Column(scale=2):
theme.py CHANGED
@@ -80,3 +80,15 @@ def adjust_theme():
80
  except:
81
  set_theme = None; print('gradio版本较旧, 不能自定义字体和颜色')
82
  return set_theme
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  except:
81
  set_theme = None; print('gradio版本较旧, 不能自定义字体和颜色')
82
  return set_theme
83
+
84
+ advanced_css = """
85
+ .markdown-body table {
86
+ border: 1px solid #ddd;
87
+ border-collapse: collapse;
88
+ }
89
+
90
+ .markdown-body th, .markdown-body td {
91
+ border: 1px solid #ddd;
92
+ padding: 5px;
93
+ }
94
+ """