Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -20,12 +20,7 @@ st.set_page_config(
|
|
20 |
layout="wide"
|
21 |
)
|
22 |
|
23 |
-
# 2.
|
24 |
-
# init_stats_file()
|
25 |
-
# init_fake_numbers_file()
|
26 |
-
# init_history_file()
|
27 |
-
|
28 |
-
# 3. Ukrycie bocznego menu Streamlit za pomoc膮 CSS
|
29 |
hide_sidebar_style = """
|
30 |
<style>
|
31 |
/* Ukryj boczne menu */
|
@@ -36,11 +31,10 @@ hide_sidebar_style = """
|
|
36 |
"""
|
37 |
st.markdown(hide_sidebar_style, unsafe_allow_html=True)
|
38 |
|
39 |
-
#
|
40 |
translations = {
|
41 |
'Polish': {
|
42 |
'menu_analysis_sms': 'Analiza wiadomo艣ci',
|
43 |
-
'menu_search_number': 'Wyszukaj numer',
|
44 |
'menu_about': 'O Projekcie',
|
45 |
'menu_education': 'Edukacja',
|
46 |
'menu_statistics': 'Statystyki',
|
@@ -51,7 +45,6 @@ translations = {
|
|
51 |
},
|
52 |
'German': {
|
53 |
'menu_analysis_sms': 'SMS-Analyse',
|
54 |
-
'menu_search_number': 'Nummernsuche',
|
55 |
'menu_about': '脺ber das Projekt',
|
56 |
'menu_education': 'Bildung',
|
57 |
'menu_statistics': 'Statistiken',
|
@@ -62,7 +55,6 @@ translations = {
|
|
62 |
},
|
63 |
'English': {
|
64 |
'menu_analysis_sms': 'SMS Analysis',
|
65 |
-
'menu_search_number': 'Search Number',
|
66 |
'menu_about': 'About the Project',
|
67 |
'menu_education': 'Education',
|
68 |
'menu_statistics': 'Statistics',
|
@@ -73,9 +65,9 @@ translations = {
|
|
73 |
}
|
74 |
}
|
75 |
|
76 |
-
#
|
77 |
if 'language' not in st.session_state:
|
78 |
-
st.session_state.language = '
|
79 |
|
80 |
# Nowy spos贸b na wyb贸r j臋zyka bez u偶ycia przycisk贸w "POST"
|
81 |
selected_language = st.selectbox(
|
@@ -92,10 +84,9 @@ st.markdown(f"**{translations[selected_language]['language_selected']} {selected
|
|
92 |
# Dodanie separatora pod wyborem j臋zyka
|
93 |
st.markdown("---")
|
94 |
|
95 |
-
#
|
96 |
menu_keys = [
|
97 |
'menu_analysis_sms',
|
98 |
-
'menu_search_number', # Newly added for number search
|
99 |
'menu_about',
|
100 |
'menu_education',
|
101 |
'menu_statistics',
|
@@ -103,7 +94,7 @@ menu_keys = [
|
|
103 |
]
|
104 |
menu_options = [translations[selected_language][key] for key in menu_keys]
|
105 |
|
106 |
-
#
|
107 |
custom_css = """
|
108 |
<style>
|
109 |
/* Stylizacja kontenera menu */
|
@@ -170,12 +161,12 @@ custom_css = """
|
|
170 |
"""
|
171 |
st.markdown(custom_css, unsafe_allow_html=True)
|
172 |
|
173 |
-
#
|
174 |
with st.container():
|
175 |
selected = option_menu(
|
176 |
menu_title=None, # Brak tytu艂u menu
|
177 |
options=menu_options,
|
178 |
-
icons=["shield-check", "
|
179 |
menu_icon=None, # Usuni臋cie ikony menu
|
180 |
default_index=0,
|
181 |
orientation="horizontal",
|
@@ -201,17 +192,14 @@ with st.container():
|
|
201 |
}
|
202 |
)
|
203 |
|
204 |
-
#
|
205 |
st.markdown("---") # Dodaje poziom膮 lini臋
|
206 |
|
207 |
-
#
|
208 |
try:
|
209 |
if selected == translations[selected_language]['menu_analysis_sms']:
|
210 |
from pages.Analysis import show_analysis
|
211 |
show_analysis(selected_language)
|
212 |
-
elif selected == translations[selected_language]['menu_search_number']:
|
213 |
-
from pages.SearchNumber import show_number_search
|
214 |
-
show_number_search(selected_language)
|
215 |
elif selected == translations[selected_language]['menu_about']:
|
216 |
from pages.About import main as show_about
|
217 |
show_about(selected_language)
|
@@ -225,7 +213,7 @@ try:
|
|
225 |
from pages.Contact import main as show_contact
|
226 |
show_contact(selected_language)
|
227 |
except ImportError as e:
|
228 |
-
st.error(f"
|
229 |
except TypeError as e:
|
230 |
-
st.error(f"
|
231 |
|
|
|
20 |
layout="wide"
|
21 |
)
|
22 |
|
23 |
+
# 2. Ukrycie bocznego menu Streamlit za pomoc膮 CSS
|
|
|
|
|
|
|
|
|
|
|
24 |
hide_sidebar_style = """
|
25 |
<style>
|
26 |
/* Ukryj boczne menu */
|
|
|
31 |
"""
|
32 |
st.markdown(hide_sidebar_style, unsafe_allow_html=True)
|
33 |
|
34 |
+
# 3. Definiowanie t艂umacze艅
|
35 |
translations = {
|
36 |
'Polish': {
|
37 |
'menu_analysis_sms': 'Analiza wiadomo艣ci',
|
|
|
38 |
'menu_about': 'O Projekcie',
|
39 |
'menu_education': 'Edukacja',
|
40 |
'menu_statistics': 'Statystyki',
|
|
|
45 |
},
|
46 |
'German': {
|
47 |
'menu_analysis_sms': 'SMS-Analyse',
|
|
|
48 |
'menu_about': '脺ber das Projekt',
|
49 |
'menu_education': 'Bildung',
|
50 |
'menu_statistics': 'Statistiken',
|
|
|
55 |
},
|
56 |
'English': {
|
57 |
'menu_analysis_sms': 'SMS Analysis',
|
|
|
58 |
'menu_about': 'About the Project',
|
59 |
'menu_education': 'Education',
|
60 |
'menu_statistics': 'Statistics',
|
|
|
65 |
}
|
66 |
}
|
67 |
|
68 |
+
# 4. Wyb贸r j臋zyka z flagami w jednym wierszu
|
69 |
if 'language' not in st.session_state:
|
70 |
+
st.session_state.language = 'English' # Default to English
|
71 |
|
72 |
# Nowy spos贸b na wyb贸r j臋zyka bez u偶ycia przycisk贸w "POST"
|
73 |
selected_language = st.selectbox(
|
|
|
84 |
# Dodanie separatora pod wyborem j臋zyka
|
85 |
st.markdown("---")
|
86 |
|
87 |
+
# 5. Pobranie przet艂umaczonych opcji menu
|
88 |
menu_keys = [
|
89 |
'menu_analysis_sms',
|
|
|
90 |
'menu_about',
|
91 |
'menu_education',
|
92 |
'menu_statistics',
|
|
|
94 |
]
|
95 |
menu_options = [translations[selected_language][key] for key in menu_keys]
|
96 |
|
97 |
+
# 6. Dodanie niestandardowego CSS do wzmocnienia styl贸w menu
|
98 |
custom_css = """
|
99 |
<style>
|
100 |
/* Stylizacja kontenera menu */
|
|
|
161 |
"""
|
162 |
st.markdown(custom_css, unsafe_allow_html=True)
|
163 |
|
164 |
+
# 7. Tworzenie poziomego menu w kontenerze
|
165 |
with st.container():
|
166 |
selected = option_menu(
|
167 |
menu_title=None, # Brak tytu艂u menu
|
168 |
options=menu_options,
|
169 |
+
icons=["shield-check", "info-circle", "book", "bar-chart", "envelope"],
|
170 |
menu_icon=None, # Usuni臋cie ikony menu
|
171 |
default_index=0,
|
172 |
orientation="horizontal",
|
|
|
192 |
}
|
193 |
)
|
194 |
|
195 |
+
# 8. Dodanie separatora
|
196 |
st.markdown("---") # Dodaje poziom膮 lini臋
|
197 |
|
198 |
+
# 9. Importowanie i wywo艂ywanie modu艂贸w dla ka偶dej zak艂adki
|
199 |
try:
|
200 |
if selected == translations[selected_language]['menu_analysis_sms']:
|
201 |
from pages.Analysis import show_analysis
|
202 |
show_analysis(selected_language)
|
|
|
|
|
|
|
203 |
elif selected == translations[selected_language]['menu_about']:
|
204 |
from pages.About import main as show_about
|
205 |
show_about(selected_language)
|
|
|
213 |
from pages.Contact import main as show_contact
|
214 |
show_contact(selected_language)
|
215 |
except ImportError as e:
|
216 |
+
st.error(f"Import error: {e}")
|
217 |
except TypeError as e:
|
218 |
+
st.error(f"Function call error: {e}")
|
219 |
|