eee_alarm_clock/clock/ui/main_clock.py

42 lines
1.3 KiB
Python

import curses
from datetime import datetime
from .utils import init_colors, draw_big_digit
from .big_digits import BIG_DIGITS
from .add_alarm import draw_add_alarm
from .active_alarm import draw_active_alarms
from .list_alarms import draw_list_alarms
def draw_main_clock(stdscr, context=None):
"""Draw the main clock screen"""
init_colors()
height, width = stdscr.getmaxyx()
current_time = datetime.now()
# Big time display
time_str = current_time.strftime("%H:%M:%S")
digit_width = 14 # Width of each digit pattern
total_width = digit_width * len(time_str)
start_x = (width - total_width) // 2
start_y = (height - 7) // 2 - 4
# Green color for big time
stdscr.attron(curses.color_pair(1))
for i, digit in enumerate(time_str):
draw_big_digit(stdscr, start_y, start_x + i * digit_width, digit)
stdscr.attroff(curses.color_pair(1))
# Date display
date_str = current_time.strftime("%Y-%m-%d")
date_x = width // 2 - len(date_str) // 2
date_y = height // 2 + 4
stdscr.attron(curses.color_pair(2))
stdscr.addstr(date_y, date_x, date_str)
stdscr.attroff(curses.color_pair(2))
# Menu options
menu_str = "A: Add Alarm S: List Alarms Q: Quit"
menu_x = width // 2 - len(menu_str) // 2
stdscr.addstr(height - 2, menu_x, menu_str)