-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathst.py
More file actions
93 lines (63 loc) · 2.85 KB
/
Copy pathst.py
File metadata and controls
93 lines (63 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
from tutorialcreator.renderer import OutputFormat
import streamlit as st
import logging
import tutorialcreator as tc
logger = logging.getLogger(__name__)
logger.info('Starting GUI')
st.set_page_config(page_title="Tutorial Creator", layout="wide")
st.title("Statistics Tutorial Creator", text_alignment="center")
with st.container():
col1, col2 = st.columns(2)
with col1.container():
selected_module = st.selectbox("Select a Module", ("STSM3714", "STSM2624"))
selected_tutorial = st.selectbox("Select a Tutorial", tc.list_tutorials())
selected_output_format = st.selectbox(
"Select an output format", ("pdf", "docx", "html")
)
with col2.container():
st.subheader("Seed")
selected_seed = st.text_input("Seed", value="42")
tut,cfg= tc.select_tutorial(
subject=selected_module, tutorial_id=selected_tutorial
)
header = cfg.get_header()
cfg.set_seed(seed=int(selected_seed))
def render_click() -> None:
logger.info('Rendering tutorial from GUI')
with st.spinner("Rendering Tutorial ..."):
if selected_output_format == "pdf":
logger.info('Rendering to pdf')
tc.build(tut,cfg,OutputFormat.PDF)
elif selected_output_format == "html":
logger.info('Rendering to html')
tc.build(tut,cfg,OutputFormat.HTML)
else:
logger.info('Rendering to docx')
tc.build(tut,cfg,OutputFormat.WORD)
st.button(label="Render", on_click=render_click)
with st.container():
col1, col2 = st.columns(2)
with col1.container():
st.subheader("Set Header")
header = cfg.get_header()
selected_title = st.text_input(label="title", value=header["title"])
selected_author = st.text_input(label="author", value=header["author"])
selected_uni = st.text_input(label="University", value=header["university"])
selected_dept = st.text_input(label="Department", value=header["department"])
selected_mc = st.text_input(label="Module Code", value=header["module_code"])
selected_mo = st.text_input(label="Module Name", value=header["module_name"])
selected_dd = st.text_input(label="Due date", value=header["due_date"])
selected_tm = st.slider("Total Marks", 0, 100, 50)
new_header_ctx = {
"title": selected_title,
"author": selected_author,
"university": selected_uni,
"department": selected_dept,
"module_code": selected_mc,
"module_name": selected_mo,
"due_date": selected_dd,
"total_marks": selected_tm,
}
cfg.set_header(**new_header_ctx)
with col2.container():
st.write(cfg.get_header())