Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.67 KB | None | 0 0
  1. import ui
  2. import appex
  3. from datetime import date, datetime, time
  4. import calendar
  5.  
  6. MondayA = {'P1': 'Free','P2': 'Free','T': 'Tutor','P3': 'Ethics','P4': 'Free','P5': 'IT'}
  7. TuesdayA = {'P1': 'Computing','P2': 'Computing','T': 'Ext. Break','P3': 'IT','P4': 'Free','P5': 'Free'}
  8. WednesdayA = {'P1': 'Philosophy','P2': 'IT','T': 'Tutor','P3': 'English','P4': 'Computing','P5': ''}
  9. ThursdayA = {'P1': 'Free','P2': 'Ethics','T': 'Ext. Break','P3': 'Core Maths','P4': 'English','P5': 'Free'}
  10. FridayA = {'P1': 'Computing','P2': 'IT','T': 'Assembly','P3': 'IT','P4': 'Philosophy','P5': 'Free'}
  11. MondayB = {'P1': 'Free','P2': 'Free','T': 'Tutor','P3': 'Computing','P4': 'Ethics','P5': 'Free'}
  12. TuesdayB = {'P1': 'Ethics','P2': 'Computing','T': 'Ext. Break','P3': 'Free','P4': 'Free','P5': 'IT'}
  13. WednesdayB = {'P1': 'Core Maths','P2': 'Free','T': 'Tutor','P3': 'Tutor','P4': 'Philosophy','P5': ''}
  14. ThursdayB = {'P1': 'Free','P2': 'IT','T': 'Ext. Break','P3': 'Computing','P4': 'Free','P5': 'Philosophy'}
  15. FridayB = {'P1': 'IT','P2': 'Computing','T': 'Assembly','P3': 'Free','P4': 'Free','P5': 'Core Maths'}
  16.  
  17. my_date = date.today()
  18. Week = 'A' # Set the Week Here
  19. Day = calendar.day_name[my_date.weekday()]
  20. Day = 'Wednesday'
  21. DayWeek = Day + Week
  22. Switch = 'no'
  23.  
  24. Period1S = "Period 1: " + eval(DayWeek + "['P1']")
  25. Period2S = "Period 2: " + eval(DayWeek + "['P2']")
  26. TutorS = "Tutor: " + eval(DayWeek + "['T']")
  27. Period3S = "Period 3: " + eval(DayWeek + "['P3']")
  28. Period4S = "Period 4: " + eval(DayWeek + "['P4']")
  29. Period5S = "Period 5: " + eval(DayWeek + "['P5']")
  30.  
  31. v = ui.load_view()
  32.  
  33. btn = v['switch']
  34. p1 = v['p1']
  35. p2 = v['p2']
  36. t = v['t']
  37. p3 = v['p3']
  38. p4 = v['p4']
  39. p5 = v['p5']
  40. p1.text = Period1S
  41. p2.text = Period2S
  42. t.text = TutorS
  43. p3.text = Period3S
  44. p4.text = Period4S
  45. p5.text = Period5S
  46. now = datetime.now()
  47. now_time = now.time()
  48.  
  49. if Day != 'Wednesday':
  50. Period1T = "Period 1: 8:50 - 9:50"
  51. Period2T = "Period 2: 9:53 - 10:53"
  52. TutorT = "Tutor: 10:53 - 11:13"
  53. Period3T = "Period 3: 11:33 - 12:33"
  54. Period4T = "Period 4: 1:11 - 2:11"
  55. Period5T = "Period 5: 2:14 - 3:14"
  56. if now_time >= time(8,50) and now_time <= time(9,50):
  57. p1.text_color = 'green'
  58. if now_time >= time(9,53) and now_time <= time(10,53):
  59. p2.text_color = 'green'
  60. if now_time >= time(10,53) and now_time <= time(11,13):
  61. t.text_color = 'green'
  62. if now_time >= time(11,33) and now_time <= time(12,33):
  63. p3.text_color = 'green'
  64. if now_time >= time(13,11) and now_time <= time(14,11):
  65. p4.text_color = 'green'
  66. if now_time >= time(13,14) and now_time <= time(15,14):
  67. p5.text_color = 'green'
  68. elif Day == 'Wednesday':
  69. Period1T = "Period 1: 8:50 - 9:50"
  70. Period2T = "Period 2: 10:30 - 11:30"
  71. TutorT = "Tutor: 9:50 - 10:10"
  72. Period3T = "Period 3: 12:08 - 1:08"
  73. Period4T = "Period 4: 1:11 - 2:11"
  74. Period5T = "Period 5:"
  75. if now_time >= time(8,50) and now_time <= time(9,50):
  76. p1.text_color = 'green'
  77. if now_time >= time(10,30) and now_time <= time(11,30):
  78. p2.text_color = 'green'
  79. if now_time >= time(9,50) and now_time <= time(10,10):
  80. t.text_color = 'green'
  81. if now_time >= time(12,8) and now_time <= time(13,8):
  82. p3.text_color = 'green'
  83. if now_time >= time(13,11) and now_time <= time(14,11):
  84. p4.text_color = 'green'
  85.  
  86. def switch(sender):
  87. global Switch
  88. if Switch == 'no':
  89. p1.text = Period1T
  90. p2.text = Period2T
  91. t.text = TutorT
  92. p3.text = Period3T
  93. p4.text = Period4T
  94. p5.text = Period5T
  95. Switch = 'yes'
  96. elif Switch == 'yes':
  97. p1.text = Period1S
  98. p2.text = Period2S
  99. t.text = TutorS
  100. p3.text = Period3S
  101. p4.text = Period4S
  102. p5.text = Period5S
  103. Switch = 'no'
  104.  
  105. btn.action = switch
  106. appex.set_widget_view(v)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement