1
0

full_calendar_documentation.py 832 B

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