Delete catppuccin_main.py
Browse files- catppuccin_main.py +0 -50
catppuccin_main.py
DELETED
@@ -1,50 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
import re
|
3 |
-
import shutil
|
4 |
-
import gradio as gr
|
5 |
-
from modules import script_callbacks
|
6 |
-
from modules import shared, scripts
|
7 |
-
import modules.scripts as scripts
|
8 |
-
|
9 |
-
accents = ['rosewater', 'flamingo', 'pink' , 'mauve' ,'red', 'maroon' ,'peach', 'yellow', 'green', 'teal', 'sky', 'blue', 'sapphire', 'lavender']
|
10 |
-
flavors = ['latte', 'frappe', 'macchiato', 'mocha']
|
11 |
-
script_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
|
12 |
-
|
13 |
-
def on_ui_settings():
|
14 |
-
section = ('ctp', 'Catppuccin Theme')
|
15 |
-
shared.opts.add_option("ctp_flavor",
|
16 |
-
shared.OptionInfo(
|
17 |
-
default='mocha',
|
18 |
-
label="Catppuccin Flavor",
|
19 |
-
component=gr.Radio,
|
20 |
-
component_args={"choices": flavors},
|
21 |
-
onchange=on_ui_settings_change,
|
22 |
-
section=section))
|
23 |
-
|
24 |
-
shared.opts.add_option("accent_color",
|
25 |
-
shared.OptionInfo(
|
26 |
-
default='sapphire',
|
27 |
-
label='Accent',
|
28 |
-
component=gr.Radio,
|
29 |
-
component_args={"choices": accents},
|
30 |
-
onchange=on_accent_color_change,
|
31 |
-
section=section
|
32 |
-
))
|
33 |
-
|
34 |
-
def on_accent_color_change():
|
35 |
-
pattern = re.compile(r"--accent:\s*(.*)")
|
36 |
-
# replace the accent color
|
37 |
-
with open(os.path.join(script_path,'style.css'), "r+") as file:
|
38 |
-
text = re.sub(pattern, f'--accent: var(--{shared.opts.accent_color});', file.read(), count=1)
|
39 |
-
file.seek(0)
|
40 |
-
file.write(text)
|
41 |
-
file.truncate()
|
42 |
-
|
43 |
-
def on_ui_settings_change():
|
44 |
-
# Move css over
|
45 |
-
shutil.copy(os.path.join(script_path,f'flavors/{shared.opts.ctp_flavor}.css'), os.path.join(script_path, 'style.css'))
|
46 |
-
|
47 |
-
# reappply accent color
|
48 |
-
on_accent_color_change()
|
49 |
-
|
50 |
-
script_callbacks.on_ui_settings(on_ui_settings)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|