implemented the statistics output window, slightly improved the logic, and completed the program design.
This commit is contained in:
@@ -1,8 +1,13 @@
|
|||||||
|
# Main window
|
||||||
|
|
||||||
# 1. Заставляем окно всегда открываться в плавающем режиме
|
# 1. Заставляем окно всегда открываться в плавающем режиме
|
||||||
windowrule = match:class ^(Focustimer)$, float 1
|
windowrule = match:title ^(Focus-Timer)$, float 1
|
||||||
|
# 2. Жестко задаем ему начальный размер на уровне оконного менеджера
|
||||||
# 2. Задаем ему начальный размер на уровне оконного менеджера
|
windowrule = match:title ^(Focus-Timer)$, size 120 140
|
||||||
windowrule = match:class ^(Focustimer)$, size 120 140
|
|
||||||
|
|
||||||
# 3. Прикалываем окно, чтобы оно отображалось на всех воркспейсах
|
# 3. Прикалываем окно, чтобы оно отображалось на всех воркспейсах
|
||||||
windowrule = match:class ^(Focustimer)$, pin 1
|
windowrule = match:title ^(Focus-Timer)$, pin 1
|
||||||
|
|
||||||
|
# Toplevel window
|
||||||
|
|
||||||
|
windowrule = match:title ^(Statistics)$, float 1
|
||||||
|
windowrule = match:title ^(Statistics)$, size 180 200
|
||||||
|
|||||||
58
main.py
58
main.py
@@ -1,6 +1,7 @@
|
|||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
import os
|
import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from customtkinter import CTkScrollableFrame, CTkLabel
|
||||||
|
|
||||||
STORAGE_PATH = os.path.expanduser("~/.config/focus-timer/data.txt")
|
STORAGE_PATH = os.path.expanduser("~/.config/focus-timer/data.txt")
|
||||||
|
|
||||||
@@ -56,7 +57,7 @@ def handle_transition():
|
|||||||
match current_state:
|
match current_state:
|
||||||
case "FOCUS":
|
case "FOCUS":
|
||||||
current_state = STATE_WORK
|
current_state = STATE_WORK
|
||||||
seconds_left = 4200
|
seconds_left = 42 # 4200
|
||||||
distractions = 0
|
distractions = 0
|
||||||
|
|
||||||
case "WORK":
|
case "WORK":
|
||||||
@@ -74,7 +75,7 @@ def start_button_f():
|
|||||||
global current_state, seconds_left, distractions
|
global current_state, seconds_left, distractions
|
||||||
distractions = 0
|
distractions = 0
|
||||||
current_state = STATE_FOCUS
|
current_state = STATE_FOCUS
|
||||||
seconds_left = 1200
|
seconds_left = 12 # 1200
|
||||||
|
|
||||||
tick()
|
tick()
|
||||||
update_ui()
|
update_ui()
|
||||||
@@ -98,14 +99,13 @@ def break_button_f():
|
|||||||
global current_state, seconds_left
|
global current_state, seconds_left
|
||||||
|
|
||||||
current_state = STATE_BREAK
|
current_state = STATE_BREAK
|
||||||
seconds_left = 1500
|
seconds_left = 15 # 1500
|
||||||
update_timer_label()
|
update_timer_label()
|
||||||
|
|
||||||
create_post()
|
create_post()
|
||||||
update_ui()
|
update_ui()
|
||||||
|
|
||||||
def complete_task_button_f():
|
def complete_task_button_f():
|
||||||
create_post()
|
|
||||||
break_button_f()
|
break_button_f()
|
||||||
|
|
||||||
def create_post():
|
def create_post():
|
||||||
@@ -169,12 +169,57 @@ def update_ui():
|
|||||||
start_button.config(fg="yellow", activebackground="yellow")
|
start_button.config(fg="yellow", activebackground="yellow")
|
||||||
start_button.pack(side="bottom", pady="15")
|
start_button.pack(side="bottom", pady="15")
|
||||||
|
|
||||||
|
def open_stats_window(event):
|
||||||
|
st_win = tk.Toplevel()
|
||||||
|
st_win.title("Statistics")
|
||||||
|
st_win.configure(background="#17153b")
|
||||||
|
st_win.geometry("180x200")
|
||||||
|
st_win.minsize(180, 200)
|
||||||
|
st_win.maxsize(180, 200)
|
||||||
|
st_win.resizable(False, False)
|
||||||
|
|
||||||
|
|
||||||
|
lines= []
|
||||||
|
if os.path.exists(STORAGE_PATH):
|
||||||
|
with open(STORAGE_PATH, "r", encoding="utf-8") as f:
|
||||||
|
for line in f:
|
||||||
|
line = line.strip()
|
||||||
|
if line and ":" in line:
|
||||||
|
lines.append(line)
|
||||||
|
else:
|
||||||
|
show_problems_label(st_win)
|
||||||
|
|
||||||
|
|
||||||
|
if lines:
|
||||||
|
scroll_frame = CTkScrollableFrame(st_win)
|
||||||
|
scroll_frame.configure(fg_color="#c8acd6", corner_radius=10)
|
||||||
|
scroll_frame.pack(fill="both", expand=True, padx=10, pady=15)
|
||||||
|
with open(STORAGE_PATH, "r", encoding="utf-8") as f:
|
||||||
|
line_c = 1
|
||||||
|
for line in f:
|
||||||
|
line = line.strip()
|
||||||
|
if line_c % 2 == 0:
|
||||||
|
label_c1 = CTkLabel(scroll_frame, text=line, font=("Helvetica", 16), fg_color="#975fb3", text_color="black", corner_radius=15)
|
||||||
|
label_c1.pack(side="top", fill="x", pady=2, expand=True)
|
||||||
|
else:
|
||||||
|
label_c2 = CTkLabel(scroll_frame, text=line, font=("Helvetica", 16), fg_color="#af74cc", text_color="black", corner_radius=15)
|
||||||
|
label_c2.pack(side="top", fill="x", pady=5, expand=True)
|
||||||
|
line_c += 1
|
||||||
|
else:
|
||||||
|
show_problems_label(st_win)
|
||||||
|
|
||||||
|
|
||||||
|
def show_problems_label(master):
|
||||||
|
info_label = tk.Label(master, text="No one entries have been\n registered yet.\n Or file does not exist. \n :(", bg="#17153b", fg="#C8ACD6", font=("Helvetica", 16))
|
||||||
|
info_label.pack(anchor="center", fill="both", expand=True)
|
||||||
|
|
||||||
text_label = tk.Label(app, font=("Helvetica", 14, "bold"), bg="#17153b")
|
text_label = tk.Label(app, font=("Helvetica", 14, "bold"), bg="#17153b")
|
||||||
text_label.pack(side="top", pady="15")
|
text_label.pack(side="top", pady="15")
|
||||||
|
|
||||||
timer_label = tk.Label(app, text="hh:mm:ss",fg="#C8ACD6",background="#17153B",font=("Helvetica", 25) , anchor="center")
|
timer_label = tk.Label(app, text="hh:mm:ss",fg="#C8ACD6",background="#17153B",font=("Helvetica", 25) , anchor="center")
|
||||||
timer_label.pack(expand=True,fill="y")
|
timer_label.pack(expand=True,fill="y")
|
||||||
|
|
||||||
|
|
||||||
start_button = tk.Button(app, text="Start.", command=start_button_f, activeforeground="black", background="#17153b", relief="flat", bd="0")
|
start_button = tk.Button(app, text="Start.", command=start_button_f, activeforeground="black", background="#17153b", relief="flat", bd="0")
|
||||||
|
|
||||||
distracted_button = tk.Button(app, text="I got distracted.", command=distracted_button_f, fg="red", bg="#17153b", relief="flat", bd="0", activebackground="red", activeforeground="black")
|
distracted_button = tk.Button(app, text="I got distracted.", command=distracted_button_f, fg="red", bg="#17153b", relief="flat", bd="0", activebackground="red", activeforeground="black")
|
||||||
@@ -183,5 +228,10 @@ complete_task_button = tk.Button(app, text="Complete the task.", command=complet
|
|||||||
|
|
||||||
break_button = tk.Button(app, text="Go break :3", command=break_button_f, fg="orange", bg="#17153b", relief="flat", bd="0", activebackground="orange", activeforeground="black")
|
break_button = tk.Button(app, text="Go break :3", command=break_button_f, fg="orange", bg="#17153b", relief="flat", bd="0", activebackground="orange", activeforeground="black")
|
||||||
|
|
||||||
|
|
||||||
|
app.bind("<Alt-s>", open_stats_window)
|
||||||
|
app.bind("<Alt-Cyrillic_yeru>", open_stats_window)
|
||||||
|
|
||||||
|
|
||||||
update_ui()
|
update_ui()
|
||||||
app.mainloop()
|
app.mainloop()
|
||||||
|
|||||||
Reference in New Issue
Block a user