将css样式移动到theme文件,减少main.py的代码行数
This commit is contained in:
		
							parent
							
								
									364810983a
								
							
						
					
					
						commit
						639e24fc82
					
				
							
								
								
									
										16
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								main.py
									
									
									
									
									
								
							@ -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):
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										12
									
								
								theme.py
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								theme.py
									
									
									
									
									
								
							@ -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;
 | 
			
		||||
}
 | 
			
		||||
"""
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user