spanish-task-generator / pages /3_📥_Скачать.py
a-v-bely
Update interface
8cde930
import streamlit as st
from utilities_ui.custom_download_button import download_button as d_button
st.set_page_config(page_title='Скачать', layout="wide", page_icon=':es:', initial_sidebar_state='collapsed')
if st.session_state.get('-LOGGED_IN_BOOL-') and (st.session_state.get('-DISPLAY_READY-')
or st.session_state.get('-DOWNLOAD_VERSION-')):
result = st.session_state.get('RESULT')
if result is None:
st.error('Не можем ничего загрузить! Вы ничего не просили!')
st.stop()
# Download buttons
if st.session_state.get('-DOWNLOAD_VERSION-'):
invite, tasks_col, tasks_with_answers_col, keys_only_col, full_coll, rest = st.columns([1, 1, 2, 1, 3, 1])
invite.write('Скачать:')
with tasks_col:
d_button(
label='Задания',
data=result['STUDENT_OUT'],
file_name=f'{result["name"]}_tasks.txt')
with tasks_with_answers_col:
d_button(
label='Задания+Ключи',
data=result['TEACHER_OUT'],
file_name=f'{result["name"]}_tasks_and_keys.txt')
with keys_only_col:
d_button(
label='Ключи',
data=result['KEYS_ONLY'],
file_name=f'{result["name"]}_keys.txt')
with full_coll:
d_button(
label='Исходник+Задания+Ключи',
data=result['TOTAL_OUT'],
file_name=f'{result["name"]}_all.txt')
if st.session_state.get('-DISPLAY_VERSION-'):
display_tasks_with_answers, display_tasks_only = st.tabs(['Задания+Ответы', 'Задания'])
display_tasks_with_answers.write(str(result['TEACHER_OUT'].replace('_', '\_')))
display_tasks_only.write(str(result['STUDENT_OUT'].replace('_', '\_')))
elif st.session_state.get('-LOGGED_IN_BOOL-'):
st.warning('**Сначала введите текст**')
else:
st.warning('**Войдите или зарегистрируйтесь**')