Repository navigation
Expand file tree
/
Copy pathapp.py
More file actions
50 lines (36 loc) · 1.48 KB
/
Copy pathapp.py
File metadata and controls
50 lines (36 loc) · 1.48 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
"""Simple Time Tracker — a Streamlit port of the Android app.
Run with: streamlit run app.py
"""
from __future__ import annotations
import streamlit as st
from timetracker.ui import activities, goals, records, running, settings, statistics
st.set_page_config(
page_title="Simple Time Tracker",
page_icon="⏱️",
layout="wide",
initial_sidebar_state="expanded",
)
PAGES = [
st.Page(running.render, title="Timers", icon="⏱️", default=True),
st.Page(records.render, title="Records", icon="📋", url_path="records"),
st.Page(statistics.render, title="Statistics", icon="📊", url_path="statistics"),
st.Page(goals.render, title="Goals", icon="🎯", url_path="goals"),
st.Page(activities.render, title="Activities", icon="🗂️", url_path="activities"),
st.Page(settings.render, title="Settings", icon="⚙️", url_path="settings"),
]
def main() -> None:
with st.sidebar:
st.markdown("### ⏱️ Simple Time Tracker")
st.caption("Track how much time you spend on all the useless activities in the world.")
_first_run_hint()
st.navigation(PAGES).run()
def _first_run_hint() -> None:
"""An empty database is not much to look at — offer to fill it."""
from timetracker.seed import database_is_empty, seed_demo_data
if not database_is_empty():
return
st.info("The database is empty.")
if st.button("Load demo data", use_container_width=True):
seed_demo_data()
st.rerun()
main()