full_calendar_documentation.py 909 B

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