From 623b4bf248dfcf2a5131dbd5c7f19d453185ff6c Mon Sep 17 00:00:00 2001 From: Artus Date: Tue, 31 Mar 2020 15:31:56 +0200 Subject: [PATCH] starts first draft --- xerus/__main__.py | 80 +++++++++++++++++++++++++++++++++++++++++++++++ xerus/notes.py | 16 ++++++++++ 2 files changed, 96 insertions(+) create mode 100644 xerus/__main__.py create mode 100644 xerus/notes.py diff --git a/xerus/__main__.py b/xerus/__main__.py new file mode 100644 index 0000000..612359e --- /dev/null +++ b/xerus/__main__.py @@ -0,0 +1,80 @@ +# -*- coding:utf-8 -*- + +import tkinter as tk +from tkinter import ttk + +def new_frame_horiz(parent): + frame = tk.Frame(parent) + frame.pack(fill=tk.X, expand=True) + return frame + +window = tk.Tk() +window.title("Xerus") + +header = tk.Frame(window) +header.pack(side=tk.TOP, fill=tk.X, expand=True) + +# Subjects choice list +subjectFrame = new_frame_horiz(header) +subjects = ["Henri", "Étienne", "Julia"] +subjectLabel = tk.Label(subjectFrame, text="Résident") +subjectLabel.pack(side=tk.LEFT) +subjectChoice = ttk.Combobox(subjectFrame, values=subjects) +subjectChoice.pack(side=tk.RIGHT, expand=True, fill=tk.X) + +# Category choice list +categoryFrame = new_frame_horiz(header) +categories = ["Santé", "Comportement", "Quotidien", "Infos", "Activité"] +categoryLabel = tk.Label(categoryFrame, text="Catégorie") +categoryLabel.pack(side=tk.LEFT) +categoryChoice = ttk.Combobox(categoryFrame, values=categories) +categoryChoice.current(0) +toLeft = tk.Button(categoryFrame, text="<") +toRight = tk.Button(categoryFrame, text=">") + +toRight.pack(side=tk.RIGHT) +categoryChoice.pack(side=tk.RIGHT, fill=tk.X, expand=True) +toLeft.pack(side=tk.RIGHT) + + +# Text view +textView = tk.Frame(window) +textView.pack() + +textStore = { + "23 mars 2020": [ + { 'time': "Matin", 'text': "Bien mangé ce matin. Sorti faire un tour pour voir les poules", }, + { 'time': "Après-midi", 'text': "Rien de particulier" }, + ], + "24 mars 2020": [ + { 'time': "Matin", 'text': "Bien mangé ce matin. Sorti faire un tour pour voir les poules", }, + { 'time': "Après-midi", 'text': "Rien de particulier" }, + ], + "25 mars 2020": [ + { 'time': "Matin", 'text': "Bien mangé ce matin. Sorti faire un tour pour voir les poules", }, + { 'time': "Après-midi", 'text': "Rien de particulier" }, + ], +} + +scrollbar = tk.Scrollbar(textView) +scrollbar.pack(side=tk.RIGHT, fill=tk.Y) +text = tk.Text(textView, yscrollcommand=scrollbar.set) +scrollbar.config(command=text.yview) +text.tag_config("d", underline=1) # Dates +text.tag_config("t", foreground="grey") # Times +text.pack() + +for date, items in textStore.items(): + # Date header + text.insert(tk.INSERT, f"{date}\n\n", "d") + # Text + for i in items: + text.insert(tk.INSERT, f"{i['time']}. ", "t") + text.insert(tk.INSERT, f"{i['text']}\n") + text.insert(tk.INSERT, "\n") + +text.config(state=tk.DISABLED) + + + +window.mainloop() diff --git a/xerus/notes.py b/xerus/notes.py new file mode 100644 index 0000000..281b69e --- /dev/null +++ b/xerus/notes.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +from enum import Enum + +Category = Enum('Category', 'SANTE COMPORTEMENT QUOTIDIEN ACTIVITE INFOS') + +@dataclass +class Note: + """ A chunk of text related to a subject and a category + + It contains the content of a cell in xls table + """ + + subject: str + category: int + text: str +