Spaces:
Runtime error
Runtime error
Fix color pick from the initial config
Browse files
app.py
CHANGED
|
@@ -27,17 +27,33 @@ preset_colors: list[tuple[str, ThemeColor]] = [
|
|
| 27 |
))
|
| 28 |
]
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
default_color = preset_colors[0][1]
|
| 31 |
|
| 32 |
|
| 33 |
-
if '
|
| 34 |
-
st.session_state['primaryColor'] =
|
| 35 |
-
|
| 36 |
-
st.session_state['
|
| 37 |
-
|
| 38 |
-
st.session_state['secondaryBackgroundColor'] = st._config.get_option(f'theme.secondaryBackgroundColor') or default_color.secondaryBackgroundColor
|
| 39 |
-
if 'textColor' not in st.session_state:
|
| 40 |
-
st.session_state['textColor'] = st._config.get_option(f'theme.textColor') or default_color.textColor
|
| 41 |
|
| 42 |
|
| 43 |
st.title("Streamlit color theme editor")
|
|
|
|
| 27 |
))
|
| 28 |
]
|
| 29 |
|
| 30 |
+
if 'theme_from_initial_config' not in st.session_state:
|
| 31 |
+
config_theme_primaryColor = st._config.get_option(f'theme.primaryColor')
|
| 32 |
+
config_theme_backgroundColor = st._config.get_option(f'theme.backgroundColor')
|
| 33 |
+
config_theme_secondaryBackgroundColor = st._config.get_option(f'theme.secondaryBackgroundColor')
|
| 34 |
+
config_theme_textColor = st._config.get_option(f'theme.textColor')
|
| 35 |
+
if config_theme_primaryColor and config_theme_backgroundColor and config_theme_secondaryBackgroundColor and config_theme_textColor:
|
| 36 |
+
st.session_state['theme_from_initial_config'] = ThemeColor(
|
| 37 |
+
primaryColor=config_theme_primaryColor,
|
| 38 |
+
backgroundColor=config_theme_backgroundColor,
|
| 39 |
+
secondaryBackgroundColor=config_theme_secondaryBackgroundColor,
|
| 40 |
+
textColor=config_theme_textColor,
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
if 'theme_from_initial_config' in st.session_state:
|
| 44 |
+
preset_colors.append((
|
| 45 |
+
"From the config",
|
| 46 |
+
st.session_state['theme_from_initial_config'],
|
| 47 |
+
))
|
| 48 |
+
|
| 49 |
default_color = preset_colors[0][1]
|
| 50 |
|
| 51 |
|
| 52 |
+
if 'preset_color' not in st.session_state or 'backgroundColor' not in st.session_state or 'secondaryBackgroundColor' not in st.session_state or 'textColor' not in st.session_state:
|
| 53 |
+
st.session_state['primaryColor'] = default_color.primaryColor
|
| 54 |
+
st.session_state['backgroundColor'] = default_color.backgroundColor
|
| 55 |
+
st.session_state['secondaryBackgroundColor'] = default_color.secondaryBackgroundColor
|
| 56 |
+
st.session_state['textColor'] = default_color.textColor
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
|
| 59 |
st.title("Streamlit color theme editor")
|