full_calendar_documentation.py 786 B

1234567891011121314151617181920212223
  1. from nicegui import ui
  2. def main_demo() -> None:
  3. from datetime import datetime
  4. def format_date(dt: datetime) -> str:
  5. """Parse the date string and format it consistently."""
  6. return dt.strftime(r'%Y-%m-%d %H:%M:%S')
  7. ui.add_head_html('<script src="https://cdn.jsdelivr.net/npm/fullcalendar@6.1.9/index.global.min.js"></script>')
  8. options = {
  9. 'initialView': 'timeGridWeek',
  10. 'slotMinTime': '05:00:00',
  11. 'slotMaxTime': '22:00:00',
  12. 'allDaySlot': False,
  13. 'timeZone': 'local',
  14. 'height': 'auto',
  15. 'width': 'auto',
  16. 'events': [],
  17. }
  18. calendar = ui.fullcalendar(options, on_click=ui.notify)
  19. calendar.add_event('Math 1b03', format_date(datetime.now()), format_date(datetime.now()), color='red')