fullcalendar_test.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. from nicegui import app, ui
  2. ui.add_head_html("<script src='https://cdn.jsdelivr.net/npm/fullcalendar@6.1.9/index.global.min.js'></script>")
  3. options = {
  4. "initialView": 'timeGridWeek',
  5. "slotMinTime": "05:00:00",
  6. "slotMaxTime": "22:00:00",
  7. "allDaySlot": False,
  8. "timeZone": 'local',
  9. "height": 'auto', "events": []
  10. }
  11. title= None
  12. def func(e):
  13. global title, card
  14. title = None
  15. print(e)
  16. try:
  17. print(e.args['info']['event']['title'])
  18. title = e.args['info']['event']['title']
  19. except:
  20. pass
  21. if title:
  22. card = ui.card().style("background-color: #f0f0f0; position: absolute; z-index: 10000; top: 50%; left: 50%; transform: translate(-50%, -50%);")
  23. with card:
  24. ui.label(title)
  25. ui.button("Close", on_click=lambda e: card.delete())
  26. fullcal = ui.fullcalendar(options, on_click=lambda e: func(e))
  27. fullcal.addevent('MATH 1B03 - T06 - Linear Algebra I', '2023-10-11 09:30:00', '2023-10-11 10:20:00')
  28. fullcal.addevent('MATH 1ZA3 - C01 - Engineering Mathematics I', '2023-10-11 11:30:00', '2023-10-11 12:20:00')
  29. fullcal.addevent('COMPSCI 1MD3 - T05 - Introduction to Programming', '2023-10-11 12:30:00', '2023-10-11 13:20:00')
  30. fullcal.addevent('MATH 1B03 - C02 - Linear Algebra I', '2023-10-11 14:30:00', '2023-10-11 15:20:00')
  31. fullcal.addevent('FRENCH 1A06A - C04 - Introduction to French Studies: Advanced Level', '2023-10-11 20:00:00', '2023-10-11 22:00:00')
  32. fullcal.addevent('COMPSCI 1JC3 - C01 - Introduction to Computational Thinking', '2023-10-12 10:30:00', '2023-10-12 11:20:00')
  33. fullcal.addevent('MATH 1ZA3 - C01 - Engineering Mathematics I', '2023-10-12 11:30:00', '2023-10-12 12:20:00')
  34. fullcal.addevent('COMPSCI 1MD3 - C01 - Introduction to Programming', '2023-10-12 13:30:00', '2023-10-12 14:20:00')
  35. fullcal.addevent('MATH 1B03 - C02 - Linear Algebra I', '2023-10-12 14:30:00', '2023-10-12 15:20:00')
  36. fullcal.addevent('COMPSCI 1JC3 - C01 - Introduction to Computational Thinking', '2023-10-13 10:30:00', '2023-10-13 11:20:00')
  37. fullcal.addevent('COMPSCI 1JC3 - T01 - Introduction to Computational Thinking', '2023-10-13 11:30:00', '2023-10-13 13:20:00')
  38. fullcal.addevent('MATH 1ZA3 - T02 - Engineering Mathematics I', '2023-10-13 14:30:00', '2023-10-13 15:20:00')
  39. fullcal.addevent('MATH 1ZA3 - C01 - Engineering Mathematics I', '2023-10-16 11:30:00', '2023-10-16 12:20:00')
  40. fullcal.addevent('COMPSCI 1MD3 - C01 - Introduction to Programming', '2023-10-16 13:30:00', '2023-10-16 14:20:00')
  41. fullcal.addevent('MATH 1B03 - C02 - Linear Algebra I', '2023-10-16 14:30:00', '2023-10-16 15:20:00')
  42. fullcal.addevent('FRENCH 1A06A - T07 - Introduction to French Studies: Advanced Level', '2023-10-16 17:30:00', '2023-10-16 18:20:00')
  43. fullcal.addevent('FRENCH 1A06A - C04 - Introduction to French Studies: Advanced Level', '2023-10-16 19:00:00', '2023-10-16 20:00:00')
  44. fullcal.addevent('COMPSCI 1JC3 - C01 - Introduction to Computational Thinking', '2023-10-17 10:30:00', '2023-10-17 11:20:00')
  45. fullcal.addevent('COMPSCI 1MD3 - C01 - Introduction to Programming', '2023-10-17 14:30:00', '2023-10-17 15:20:00')
  46. fullcal.addevent('MATH 1B03 - T06 - Linear Algebra I', '2023-10-18 09:30:00', '2023-10-18 10:20:00')
  47. def add_event():
  48. global fullcal
  49. fullcal.addevent("Math 1b03", "2023-10-19 09:30:00", "2023-10-19 10:20:00")
  50. print(fullcal._props)
  51. def remove_event():
  52. global fullcal
  53. fullcal.remove_event("Math 1b03", "2023-10-19 09:30:00", "2023-10-19 10:20:00")
  54. ui.button("click me to add event", on_click=add_event)
  55. ui.button("Clcik me to delete event", on_click=remove_event)
  56. ui.run()