55 lines
1.5 KiB
Python
55 lines
1.5 KiB
Python
|
from tkinter import *
|
||
|
from tkinter import ttk
|
||
|
import sys
|
||
|
import subprocess
|
||
|
|
||
|
calendar = subprocess.check_output(["cal", "-m"])
|
||
|
calendar = calendar.decode("utf-8")
|
||
|
calendar = calendar.split("\n")
|
||
|
calendar = [x.split() for x in calendar]
|
||
|
|
||
|
today = subprocess.check_output(["date", "+\"%d\""])
|
||
|
today = today.decode("utf-8")[:-1]
|
||
|
today = today.strip("\"")
|
||
|
|
||
|
month_year = calendar[0]
|
||
|
calendar_fields = [calendar[1], calendar[2], calendar[3], calendar[4], calendar[5], calendar[6]]
|
||
|
|
||
|
root = Tk()
|
||
|
root.geometry("+0+0")
|
||
|
root.attributes("-type", "dialog")
|
||
|
|
||
|
frame = ttk.Frame(root)
|
||
|
frame.grid()
|
||
|
|
||
|
date_label = ttk.Label(frame, text=" ".join(month_year)).grid(row=0, columnspan=7)
|
||
|
prev_month_button = ttk.Button(frame, text="<", command=exit, width=1).grid(row=0, column=0)
|
||
|
next_month_button = ttk.Button(frame, text=">", command=exit, width=1).grid(row=0, column=6)
|
||
|
|
||
|
def get_agenda(date):
|
||
|
date = "2022-12-" + date
|
||
|
agenda = subprocess.check_output(["khal", "list", date, date])
|
||
|
agenda = agenda.decode("utf-8")[:-1]
|
||
|
agenda = agenda.split("\n")[1]
|
||
|
return agenda
|
||
|
|
||
|
|
||
|
row_count = 1
|
||
|
column_count = 0
|
||
|
for r in calendar_fields:
|
||
|
for c in r:
|
||
|
if c == today:
|
||
|
label = ttk.Label(frame, text=c, background="green").grid(row=row_count, column=column_count)
|
||
|
else:
|
||
|
label = ttk.Label(frame, text=c).grid(row=row_count, column=column_count)
|
||
|
column_count += 1
|
||
|
column_count = 0
|
||
|
row_count += 1
|
||
|
|
||
|
agenda_label = ttk.Label(frame, text=get_agenda(today)).grid(row=row_count+1, columnspan=7)
|
||
|
|
||
|
def exit():
|
||
|
sys.exit()
|
||
|
|
||
|
root.mainloop()
|