dritter commit, hoffentlich sind grundfunktionen da

This commit is contained in:
Dominik Schäfer
2026-08-26 06:44:54 +07:00
parent 57d4d4d8f0
commit 5ab4fc5123
9 changed files with 1011 additions and 203 deletions
+41 -68
View File
@@ -1,56 +1,40 @@
import streamlit as st
import pandas as pd
from pathlib import Path
from datetime import date, time
DATA_DIR = Path("data")
TODO_FILE = DATA_DIR / "todo.csv"
CALENDAR_FILE = DATA_DIR / "calendar.csv"
DATA_DIR.mkdir(parents=True, exist_ok=True)
TODO_COLUMNS = [
"id",
"titel",
"beschreibung",
"kategorie",
"prioritaet",
"status",
"faellig_am",
"wiederholen",
"notiz",
]
CALENDAR_COLUMNS = [
"id",
"titel",
"datum",
"uhrzeit",
"dauer_min",
"kalender",
"kategorie",
"erinnerung_min",
"wiederholen",
"notiz",
]
def load_csv(path: Path, columns: list[str]) -> pd.DataFrame:
if path.exists():
df = pd.read_csv(path)
for col in columns:
if col not in df.columns:
df[col] = ""
return df[columns]
return pd.DataFrame(columns=columns)
def save_csv(df: pd.DataFrame, path: Path) -> None:
df.to_csv(path, index=False)
def next_id(df: pd.DataFrame) -> int:
if df.empty or "id" not in df.columns:
return 1
try:
return int(df["id"].max()) + 1
except Exception:
return 1
st.set_page_config(page_title="Bitcoin-Programm", layout="wide")
st.title("Bitcoin-Programm – To-do & Kalender")
tab1, tab2, tab3 = st.tabs(["To-do anlegen", "Kalendertermin anlegen", "Daten ansehen"])
# --- To-do Formular ---
with tab1:
import pandas as pd
from pathlib import Path
from datetime import date, time
DATA_DIR = Path("data")
TODO_FILE = DATA_DIR / "todo.csv"
CALENDAR_FILE = DATA_DIR / "calendar.csv"
DATA_DIR.mkdir(parents=True, exist_ok=True)
TODO_COLUMNS = [
"id","titel","beschreibung","kategorie","prioritaet","status",
"faellig_am","wiederholen","notiz"
]
CALENDAR_COLUMNS = [
"id","titel","datum","uhrzeit","dauer_min","kalender","kategorie",
"erinnerung_min","wiederholen","notiz"
]
def load_csv(path: Path, columns: list[str]) -> pd.DataFrame:
if path.exists():
df = pd.read_csv(path)
for col in columns:
if col not in df.columns:
df[col] = ""
return df[columns]
return pd.DataFrame(columns=columns)
def save_csv(df: pd.DataFrame, path: Path) -> None:
df.to_csv(path, index=False)
def next_id(df: pd.DataFrame) -> int:
if df.empty or "id" not in df.columns:
return 1
try:
return int(df["id"].max()) + 1
except Exception:
return 1
st.set_page_config(page_title="Bitcoin-Programm", layout="wide")
st.title("Bitcoin-Programm – To-do & Kalender")
tab1, tab2, tab3 = st.tabs(["To-do anlegen", "Kalendertermin anlegen", "Daten ansehen"])
with tab1:
st.subheader("Neues To-do")
todo_df = load_csv(TODO_FILE, TODO_COLUMNS)
new_todo_id = next_id(todo_df)
@@ -82,8 +66,7 @@ with tab1:
todo_df = pd.concat([todo_df, new_row], ignore_index=True)
save_csv(todo_df, TODO_FILE)
st.success("To-do gespeichert.")
# --- Kalender Formular ---
with tab2:
with tab2:
st.subheader("Neuen Kalendereintrag")
cal_df = load_csv(CALENDAR_FILE, CALENDAR_COLUMNS)
new_cal_id = next_id(cal_df)
@@ -117,27 +100,17 @@ with tab2:
cal_df = pd.concat([cal_df, new_row], ignore_index=True)
save_csv(cal_df, CALENDAR_FILE)
st.success("Kalendertermin gespeichert.")
# --- Daten ansehen ---
with tab3:
with tab3:
st.subheader("Gespeicherte Daten")
col1, col2 = st.columns(2)
with col1:
st.markdown("### To-dos")
todo_df = load_csv(TODO_FILE, TODO_COLUMNS)
st.dataframe(todo_df, use_container_width=True)
st.download_button("To-do CSV herunterladen", data=todo_df.to_csv(index=False).encode("utf-8"), file_name="todo.csv", mime="text/csv")
with col2:
st.markdown("### Kalender")
cal_df = load_csv(CALENDAR_FILE, CALENDAR_COLUMNS)
st.dataframe(cal_df, use_container_width=True)
st.download_button(
"To-do CSV herunterladen",
data=todo_df.to_csv(index=False).encode("utf-8"),
file_name="todo.csv",
mime="text/csv",
)
st.download_button(
"Kalender CSV herunterladen",
data=cal_df.to_csv(index=False).encode("utf-8"),
file_name="calendar.csv",
mime="text/csv",
)
st.download_button("Kalender CSV herunterladen", data=cal_df.to_csv(index=False).encode("utf-8"), file_name="calendar.csv", mime="text/csv")