CoolFace
Apppublic

fufa/chatgpt

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
theme.py83 linesDownload Raw Back to root
1import gradio as gr 2 3# gradio可用颜色列表4# gr.themes.utils.colors.slate (石板色)5# gr.themes.utils.colors.gray (灰色)6# gr.themes.utils.colors.zinc (锌色)7# gr.themes.utils.colors.neutral (中性色)8# gr.themes.utils.colors.stone (石头色)9# gr.themes.utils.colors.red (红色)10# gr.themes.utils.colors.orange (橙色)11# gr.themes.utils.colors.amber (琥珀色)12# gr.themes.utils.colors.yellow (黄色)13# gr.themes.utils.colors.lime (酸橙色)14# gr.themes.utils.colors.green (绿色)15# gr.themes.utils.colors.emerald (祖母绿)16# gr.themes.utils.colors.teal (青蓝色)17# gr.themes.utils.colors.cyan (青色)18# gr.themes.utils.colors.sky (天蓝色)19# gr.themes.utils.colors.blue (蓝色)20# gr.themes.utils.colors.indigo (靛蓝色)21# gr.themes.utils.colors.violet (紫罗兰色)22# gr.themes.utils.colors.purple (紫色)23# gr.themes.utils.colors.fuchsia (洋红色)24# gr.themes.utils.colors.pink (粉红色)25# gr.themes.utils.colors.rose (玫瑰色)26 27def adjust_theme():28    try: 29        color_er = gr.themes.utils.colors.pink30        set_theme = gr.themes.Default( 31                        primary_hue=gr.themes.utils.colors.orange,32                        neutral_hue=gr.themes.utils.colors.gray,33                        font=["sans-serif", "Microsoft YaHei", "ui-sans-serif", "system-ui", "sans-serif", gr.themes.utils.fonts.GoogleFont("Source Sans Pro")], 34                        font_mono=["ui-monospace", "Consolas", "monospace", gr.themes.utils.fonts.GoogleFont("IBM Plex Mono")])35        set_theme.set(36            # Colors37            input_background_fill_dark="*neutral_800",38            # Transition39            button_transition="none",40            # Shadows41            button_shadow="*shadow_drop",42            button_shadow_hover="*shadow_drop_lg",43            button_shadow_active="*shadow_inset",44            input_shadow="0 0 0 *shadow_spread transparent, *shadow_inset",45            input_shadow_focus="0 0 0 *shadow_spread *secondary_50, *shadow_inset",46            input_shadow_focus_dark="0 0 0 *shadow_spread *neutral_700, *shadow_inset",47            checkbox_label_shadow="*shadow_drop",48            block_shadow="*shadow_drop",49            form_gap_width="1px",50            # Button borders51            input_border_width="1px",52            input_background_fill="white",53            # Gradients54            stat_background_fill="linear-gradient(to right, *primary_400, *primary_200)",55            stat_background_fill_dark="linear-gradient(to right, *primary_400, *primary_600)",56            error_background_fill=f"linear-gradient(to right, {color_er.c100}, *background_fill_secondary)",57            error_background_fill_dark="*background_fill_primary",58            checkbox_label_background_fill="linear-gradient(to top, *neutral_50, white)",59            checkbox_label_background_fill_dark="linear-gradient(to top, *neutral_900, *neutral_800)",60            checkbox_label_background_fill_hover="linear-gradient(to top, *neutral_100, white)",61            checkbox_label_background_fill_hover_dark="linear-gradient(to top, *neutral_900, *neutral_800)",62            button_primary_background_fill="linear-gradient(to bottom right, *primary_100, *primary_300)",63            button_primary_background_fill_dark="linear-gradient(to bottom right, *primary_500, *primary_600)",64            button_primary_background_fill_hover="linear-gradient(to bottom right, *primary_100, *primary_200)",65            button_primary_background_fill_hover_dark="linear-gradient(to bottom right, *primary_500, *primary_500)",66            button_primary_border_color_dark="*primary_500",67            button_secondary_background_fill="linear-gradient(to bottom right, *neutral_100, *neutral_200)",68            button_secondary_background_fill_dark="linear-gradient(to bottom right, *neutral_600, *neutral_700)",69            button_secondary_background_fill_hover="linear-gradient(to bottom right, *neutral_100, *neutral_100)",70            button_secondary_background_fill_hover_dark="linear-gradient(to bottom right, *neutral_600, *neutral_600)",71            button_cancel_background_fill=f"linear-gradient(to bottom right, {color_er.c100}, {color_er.c200})",72            button_cancel_background_fill_dark=f"linear-gradient(to bottom right, {color_er.c600}, {color_er.c700})",73            button_cancel_background_fill_hover=f"linear-gradient(to bottom right, {color_er.c100}, {color_er.c100})",74            button_cancel_background_fill_hover_dark=f"linear-gradient(to bottom right, {color_er.c600}, {color_er.c600})",75            button_cancel_border_color=color_er.c200,76            button_cancel_border_color_dark=color_er.c600,77            button_cancel_text_color=color_er.c600,78            button_cancel_text_color_dark="white",79        )80    except: 81        set_theme = None; print('gradio版本较旧, 不能自定义字体和颜色')82    return set_theme83