Skip to content

Instantly share code, notes, and snippets.

@geier
Last active June 7, 2023 19:44
Show Gist options
  • Save geier/77f7cd8ff6be3188d234 to your computer and use it in GitHub Desktop.
Save geier/77f7cd8ff6be3188d234 to your computer and use it in GitHub Desktop.
minimial test for CalendarWidget for urwid
from datetime import date as date
import urwid
from calendarwidget import CalendarWidget
PALETTE = [
('header', 'white', 'black'),
('footer', 'white', 'black'),
('line header', 'black', 'white', 'bold'),
('bright', 'dark blue', 'white', ('bold', 'standout')),
('list', 'black', 'white'),
('list focused', 'white', 'light blue', 'bold'),
('edit', 'black', 'white'),
('edit focused', 'white', 'light blue', 'bold'),
('button', 'black', 'dark cyan'),
('button focused', 'white', 'light blue', 'bold'),
('reveal focus', 'black', 'light gray'),
('today focus', 'white', 'dark magenta'),
('today', 'dark gray', 'dark green',),
('date header', 'light gray', 'black'),
('date header focused', 'black', 'white'),
('date header selected', 'dark gray', 'light gray'),
('dayname', 'light gray', ''),
('monthname', 'light gray', ''),
('weeknumber_right', 'light gray', ''),
('edit', 'white', 'dark blue'),
('alert', 'white', 'dark red'),
('mark', 'white', 'dark green'),
('frame', 'white', 'black'),
('frame focus', 'light red', 'black'),
('frame focus color', 'dark blue', 'black'),
('frame focus top', 'dark magenta', 'black'),
('editbx', 'light gray', 'dark blue'),
('editcp', 'black', 'light gray', 'standout'),
('popupbg', 'white', 'black', 'bold'),
]
keybindings = {
'today': ['T'],
'left': ['left', 'h'],
'up': ['up', 'k'],
'right': ['right', 'l'],
'down': ['down', 'j'],
}
frame = CalendarWidget(on_date_change=lambda _: None,
keybindings=keybindings,
firstweekday=0,
weeknumbers='right')
loop = urwid.MainLoop(frame, PALETTE)
frame.set_focus_date(date(2023, 5, 28))
loop.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment