Mattral commited on
Commit
6cc33f4
Β·
verified Β·
1 Parent(s): 9a5e675

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -0
app.py CHANGED
@@ -2,6 +2,48 @@ import pandas as pd
2
  import streamlit as st
3
  from difflib import SequenceMatcher
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  def read_csv_or_excel(file):
6
  # Read CSV or Excel file
7
  if file.name.endswith('.csv'):
 
2
  import streamlit as st
3
  from difflib import SequenceMatcher
4
 
5
+
6
+ ms = st.session_state
7
+ if "themes" not in ms:
8
+ ms.themes = {"current_theme": "light",
9
+ "refreshed": True,
10
+
11
+ "light": {"theme.base": "dark",
12
+ "theme.backgroundColor": "black",
13
+ "theme.primaryColor": "#c98bdb",
14
+ "theme.secondaryBackgroundColor": "#5591f5",
15
+ "theme.textColor": "white",
16
+ "theme.textColor": "white",
17
+ "button_face": "🌜"},
18
+
19
+ "dark": {"theme.base": "light",
20
+ "theme.backgroundColor": "white",
21
+ "theme.primaryColor": "#5591f5",
22
+ "theme.secondaryBackgroundColor": "#82E1D7",
23
+ "theme.textColor": "#0a1464",
24
+ "button_face": "🌞"},
25
+ }
26
+
27
+
28
+ def ChangeTheme():
29
+ previous_theme = ms.themes["current_theme"]
30
+ tdict = ms.themes["light"] if ms.themes["current_theme"] == "light" else ms.themes["dark"]
31
+ for vkey, vval in tdict.items():
32
+ if vkey.startswith("theme"): st._config.set_option(vkey, vval)
33
+
34
+ ms.themes["refreshed"] = False
35
+ if previous_theme == "dark": ms.themes["current_theme"] = "light"
36
+ elif previous_theme == "light": ms.themes["current_theme"] = "dark"
37
+
38
+
39
+ btn_face = ms.themes["light"]["button_face"] if ms.themes["current_theme"] == "light" else ms.themes["dark"]["button_face"]
40
+ st.button(btn_face, on_click=ChangeTheme)
41
+
42
+ if ms.themes["refreshed"] == False:
43
+ ms.themes["refreshed"] = True
44
+ st.rerun()
45
+
46
+
47
  def read_csv_or_excel(file):
48
  # Read CSV or Excel file
49
  if file.name.endswith('.csv'):