-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
759 lines (581 loc) · 26.7 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
# -*- coding:utf8 -*-
import os
import random
import traceback
import webbrowser
#os.environ['KIVY_TEXT']='pil'
from threading import Thread
from kivy.animation import Animation
from kivy.app import App
from kivy.core.clipboard import Clipboard
from kivy.properties import ObjectProperty, StringProperty, ListProperty, NumericProperty
from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout
from kivy.metrics import Metrics
from kivy.clock import Clock
from kivy.uix.image import Image
from kivy.uix.popup import Popup
from kivy.uix.progressbar import ProgressBar
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.core.window import Window
import data_capture_lessons
import data_lessons
from indic_transliteration import sanscript, xsanscript
from indic_transliteration.sanscript import transliterate
from kivy.utils import platform
Window.softinput_mode = 'below_target'
from kivy.config import Config
if platform !='android':
Config.remove_option('input','%(name)s')
print (Config.items('input'))
class LessonGroupScreen(Screen):
container = ObjectProperty(None)
lesson_list_names = []
def __init__(self,**kwargs):
super(LessonGroupScreen, self).__init__(**kwargs)
Window.bind(on_keyboard=self.on_key)
Clock.schedule_once(self.add_buttons,1)
def on_key(self, window, key, *args):
if key == 27: # the esc key
if self.manager.current == 'lessons':
return False
def add_buttons(self,dt):
self.list_groups = data_capture_lessons.get_groups()
self.container.bind(minimum_height=self.container.setter('height'))
for element in self.list_groups:
font_name = "Caveat-Bold.ttf"
button = Button(text=element[1],font_name=font_name,font_size="50sp",background_color=[0.76,0.83,0.86,0.8],pos_hint={'top': 1},size_hint_y=None,size_hint_x=1)
button.on_release = lambda instance=button, a=element[0]: self.switch_to_title(instance, a)
self.lesson_list_names.append(element[1])
self.container.add_widget(button)
def switch_to_title(self,i,a):
self.selected_group = a
self.manager.current ="lessons"
self.manager.transition.direction = 'left'
def launch_popup(self):
show = ImportPop()
self.popupWindow = Popup(title="Import Mini Lesson", content=show,
size_hint=(1, 0.7), auto_dismiss=False)
show.set_popupw(self.popupWindow)
show.set_screen_instance(self,self.lesson_list_names)
# open popup window
self.popupWindow.open()
class LessonListScreen(Screen):
container = ObjectProperty(None)
def __init__(self,**kwargs):
super(LessonListScreen, self).__init__(**kwargs)
Window.bind(on_keyboard=self.on_key)
def on_enter(self, *args):
groupid = self.manager.get_screen('groups').selected_group
self.list_lessons = data_capture_lessons.get_Lessons_ofgroup(groupid)
self.container.clear_widgets()
Clock.schedule_once(self.add_buttons, 1)
def on_key(self, window, key, *args):
if key == 27: # the esc key
if self.manager.current == 'lessons' :
self.manager.transition.direction = 'right'
self.manager.current = self.manager.previous()
return True
def add_buttons(self,dt):
groupid = self.manager.get_screen('groups').selected_group
self.list_lessons = data_capture_lessons.get_Lessons_ofgroup(groupid)
self.container.bind(minimum_height=self.container.setter('height'))
for element in self.list_lessons:
if element[2] is None or element[2] == "" or element[2] == "English":
font_name = "Caveat-Bold.ttf"
else:
font_name = "unifont.ttf"
button = Button(text=element[1],font_name=font_name,font_size="50sp",background_color=[0.76,0.83,0.86,0.8],pos_hint={'top': 1},size_hint_y=None,size_hint_x=1)
button.on_release = lambda instance=button, a=element[0],b=element[2]: self.switch_to_title(instance, a,b)
self.container.add_widget(button)
def switch_to_title(self,i,a,b):
if b is None or b == "" or b == "English":
self.manager.set_font("Caveat-Bold.ttf")
self.manager.set_lang("English")
else:
self.manager.set_font("unifont.ttf")
self.manager.set_lang("Hindi")
self.selected_lesson = a
self.manager.current ="title"
self.manager.transition.direction = 'left'
def set_previous_screen(self):
if self.manager.current == 'lessons':
self.manager.transition.direction = 'right'
self.manager.current = self.manager.previous()
def launch_del_popup(self):
self.popup_delete = DeletePop()
self.popup_delete.set_screen_instance(self,self.manager.get_screen('groups').selected_group)
# self.popupWindow = Popup(title="Delete Lesson", content=show,
# size_hint=(1, 0.4),auto_dismiss=True)
# show.set_popupw(self.popupWindow)
# show.set_screen_instance(self)
# open popup window
self.popup_delete.open()
class DeletePop(Popup):
lesson_list = ListProperty()
selected_lesson = StringProperty()
status_label = StringProperty()
def __init__(self, **kwargs):
super(DeletePop, self).__init__(**kwargs)
def fill_lesson_list(self):
lessons = data_capture_lessons.get_Lessons_ofgroup(self.groupid)
lessonlistdisplay = []
for element in lessons:
lesson_display = str(element[0])+":"+element[1]
lessonlistdisplay.append(lesson_display)
self.lesson_list = lessonlistdisplay
def on_select_lesson(self,lesson):
self.selected_lesson = lesson
def on_delete(self):
if self.selected_lesson != "Selected Lesson":
lesson_id = self.selected_lesson.split(":")[0]
deletion = data_lessons.delete_lesson(lesson_id)
if deletion == 0:
self.status_label = "You have deleted the selected lesson"
else:
self.status_label = "We could not delete the lesson, try again"
self.listscreen.container.clear_widgets()
self.listscreen.add_buttons(1)
def set_screen_instance(self, listscreen,groupid):
self.listscreen = listscreen
self.groupid = groupid
self.fill_lesson_list()
class ImportPop(BoxLayout):
text_userid = StringProperty()
text_classid = StringProperty()
text_lessonid = StringProperty()
text_status = StringProperty()
lesson_groups = ListProperty()
selected_group = StringProperty("Group A")
def __init__(self, **kwargs):
super(ImportPop, self).__init__(**kwargs)
self.lesson_import_flag = 0
def import_lesson(self,button_sub):
button_sub.state = "down"
print(self.text_classid+self.text_userid+self.text_lessonid)
response_code = 0
if self.lesson_import_flag == 0:
response_code, json_object = data_lessons.import_new_lesson(self.text_userid,self.text_classid,self.text_lessonid)
if response_code == 1:
self.text_status = "There was an error accessing the lesson. Check your access details."
button_sub.disabled = False
button_sub.state = "normal"
self.lesson_import_flag = 0
else:
self.text_status = "Access details correct. Downloading the lesson..."
self.call_update = Thread(target = data_lessons.update_lesson_details,args=(json_object,))
self.call_update.start()
self.progress_bar = ProgressBar()
self.popup = Popup(
title='Importing lesson',
content=self.progress_bar,
size_hint=(1, 0.3), auto_dismiss=False
)
self.popup.open()
Clock.schedule_interval(self.next, 0.5)
def next(self, dt):
groupid = ""
if self.call_update.is_alive():
self.progress_bar.value += 5
else:
if self.selected_group == "Science":
groupid = 1
elif self.selected_group == "Mathematics":
groupid = 2
elif self.selected_group == "English":
groupid = 3
elif self.selected_group == "Social Science":
groupid = 4
elif self.selected_group == "Languages":
groupid = 5
elif self.selected_group == "Other Subjects":
groupid = 6
data_capture_lessons.update_group_id(groupid)
self.popup.dismiss()
self.lesson_import_flag = 0
self.text_status ="Import Completed and the Lesson is added to the group "+self.selected_group
return False
def close_pop(self):
self.popw.dismiss()
def set_popupw(self,pop):
self.popw=pop
def set_screen_instance(self,listscreen,lessongroups):
self.listscreen =listscreen
self.lesson_groups = lessongroups
print(self.lesson_groups)
def on_select_group(self, group):
self.selected_group = group
class LessonTitleScreen(Screen):
text_label_1 = StringProperty()
text_label_2 = StringProperty()
text_image= StringProperty()
animation_count = NumericProperty()
font_name = StringProperty("Caveat-Bold.ttf")
def __init__(self,**kwargs):
super(LessonTitleScreen,self).__init__(**kwargs)
self.speak_flag = 0
Window.bind(on_keyboard=self.on_key)
def on_key(self, window, key, *args):
if key == 27: # the esc key
if self.manager.current == 'title' :
self.manager.transition.direction = 'right'
self.manager.current = 'lessons'
return True
def read_intro(self,sb_button):
sound_speak = Thread(target=data_lessons.playtextsound, args=(self.text_label_1,))
sound_speak.start()
def animate(self,dt):
# create an animation object. This object could be stored
# and reused each call or reused across different widgets.
# += is a sequential step, while &= is in parallel
self.animation_count += 1
animation = Animation(center_x=self.width/1.7, t='in_quad')
animation += Animation(center_x=self.width/2.3,t='in_quad')
# animation += Animation(pos=(200, 100), t='out_bounce')
# animation &= Animation(size=(500, 500))
# animation += Animation(size=(100, 50))
# apply the animation on the button, passed in the "instance" argument
# Notice that default 'click' animation (changing the button
# color while the mouse is down) is unchanged.
if self.animation_count == 3:
animation += Animation(center_x=self.width/2, t='in_quad')
animation.start(self.ids.tl_image)
self.animation_count = 0
return False
animation.start(self.ids.tl_image)
def reset_speak_flag(self,t):
self.speak_flag = 0
def on_enter(self):
lessonid = self.manager.get_screen('lessons').selected_lesson
self.font_name = self.manager.get_font()
title, title_image, title_running_notes = data_capture_lessons.get_title_info(lessonid)
self.text_label_1 = title_running_notes
self.text_label_2 = title
imagepath = "Lessons/Lesson"+str(lessonid)+"/images/"+title_image
if os.path.exists(imagepath) and title_image != "":
self.text_image = imagepath
else:
self.text_image = "placeholder.png"
Clock.schedule_interval(self.animate,2)
def set_previous_screen(self):
if self.manager.current == 'title':
self.manager.transition.direction = 'right'
self.manager.current = self.manager.previous()
def set_next_screen(self):
if self.manager.current == 'title':
self.manager.transition.direction = 'left'
self.manager.current = self.manager.next()
class LessonFactualScreen(Screen):
text_image_1 = StringProperty()
text_image_2 = StringProperty()
text_image_3 = StringProperty()
text_image_display = StringProperty()
font_name = StringProperty("Caveat-Bold.ttf")
text_term_description_1 = StringProperty()
text_term_description_2 = StringProperty()
text_term_description_3 = StringProperty()
text_term_description = StringProperty()
def __init__(self, **kwargs):
super(LessonFactualScreen, self).__init__(**kwargs)
Window.bind(on_keyboard=self.on_key)
def on_enter(self):
self.font_name = self.manager.get_font()
lessonid = self.manager.get_screen('lessons').selected_lesson
textimage_1, textimage_2, textimage_3 = data_capture_lessons.get_fact_images(lessonid)
text_term_1, text_term_2, text_term_3 = data_capture_lessons.get_fact_terms(lessonid)
textterm_description_1,textterm_description_2 ,textterm_description_3 = data_capture_lessons.get_fact_descriptions(lessonid)
imagepath = "Lessons/Lesson" + str(lessonid) + "/images/"
text_image1 = imagepath+textimage_1
text_image2 = imagepath + textimage_2
text_image3 = imagepath + textimage_3
self.display_index = 0
self.text_term_description_1 = text_term_1+" : "+textterm_description_1
self.text_term_description_2 = text_term_2 + " : " + textterm_description_2
self.text_term_description_3 = text_term_3 + " : " + textterm_description_3
self.text_to_read = self.text_term_description_1
self.text_term_description = self.text_term_description_1
if not os.path.exists( text_image1 ) or textimage_1 == "":
self.text_image_1 = "placeholder.png"
else:
self.text_image_1 = text_image1
if not os.path.exists(text_image2) or textimage_2 == "":
self.text_image_2 = "placeholder.png"
else:
self.text_image_2 = text_image2
if not os.path.exists(text_image3) or textimage_3 == "":
self.text_image_3 = "placeholder.png"
else:
self.text_image_3 = text_image3
self.text_image_display = self.text_image_1
def on_key(self, window, key, *args):
if key == 27: # the esc key
if self.manager.current == 'factual' :
self.manager.transition.direction = 'right'
self.manager.current = 'title'
return True
def read_aloud(self,text,button):
sound_speak = Thread(target=data_lessons.playtextsound, args=(text,))
sound_speak.start()
def load_next(self):
self.display_index += 1
if self.display_index == 3:
self.display_index = 0
if self.display_index == 0:
self.text_image_display = self.text_image_1
self.text_term_description = self.text_term_description_1
elif self.display_index == 1:
self.text_image_display = self.text_image_2
self.text_term_description = self.text_term_description_2
else:
self.text_image_display = self.text_image_3
self.text_term_description = self.text_term_description_3
def load_previous(self):
self.display_index -= 1
if self.display_index == -1:
self.display_index = 2
if self.display_index == 0:
self.text_image_display = self.text_image_1
self.text_term_description = self.text_term_description_1
elif self.display_index == 1:
self.text_image_display = self.text_image_2
self.text_term_description = self.text_term_description_2
else:
self.text_image_display = self.text_image_3
self.text_term_description = self.text_term_description_3
def set_previous_screen(self):
if self.manager.current == 'factual':
self.manager.transition.direction = 'right'
self.manager.current = self.manager.previous()
def set_next_screen(self):
if self.manager.current == 'factual':
self.manager.transition.direction = 'left'
self.manager.current = self.manager.next()
class imgpopup(Popup):
text_image = StringProperty()
text_step = StringProperty()
text_no_image = StringProperty()
def set_text(self,text_image,text_step,text_no_image):
self.text_image = text_image
self.text_step = text_step
self.text_no_image = text_no_image
class imgpopupall(Popup):
text_step = StringProperty()
text_no_image = StringProperty()
def set_text(self,title,text_no_image):
self.text_step = title
self.text_no_image = text_no_image
class LessonApplyScreen(Screen):
text_label_1 = StringProperty("Dynamic Text"+str(random.randint(1,100)))
text_label_2 = StringProperty("test.png")
steps = ObjectProperty(None)
font_name = StringProperty("Caveat-Bold.ttf")
def __init__(self,**kwargs):
super(LessonApplyScreen, self).__init__(**kwargs)
Window.bind(on_keyboard=self.on_key)
def on_key(self, window, key, *args):
if key == 27: # the esc key
if self.manager.current == 'apply' :
self.manager.transition.direction = 'right'
self.manager.current = 'notes'
return True
def on_enter(self):
self.font_name = self.manager.get_font()
self.lessonid = self.manager.get_screen('lessons').selected_lesson
self.number_of_steps = data_capture_lessons.get_number_of_steps(self.lessonid)
self.step_list = data_capture_lessons.get_description_list(self.lessonid)
self.image_list = data_capture_lessons.get_step_image_list(self.lessonid)
self.add_steps_buttons()
def set_previous_screen(self):
if self.manager.current == 'apply':
self.manager.transition.direction = 'right'
self.manager.current = self.manager.previous()
def set_next_screen(self):
if self.manager.current == 'apply':
self.manager.transition.direction = 'left'
self.manager.current = self.manager.next()
def add_steps_buttons(self):
self.button_list = []
self.steps.clear_widgets()
# self.images.clear_widgets()
if platform != 'android':
textsize = (1200,None)
else:
textsize = (2.0*Metrics.dpi, None)
for i in range(8):
if self.step_list[i] is None or self.step_list[i] == "":
break
button = Button(text=self.step_list[i],font_name=self.font_name, size_hint_y=None,size_hint_x=1,height="70sp"
,background_color=[0.76,0.83,0.86,0.8],text_size=textsize,font_size='50sp')
self.button_list.append(button)
button.on_release = lambda instance=button,a =i: self.add_image(instance,a)
self.steps.add_widget(button)
button1 = Button(text="View All",font_name=self.font_name, size_hint_y=None, size_hint_x=1, height="70sp"
, background_color=[0.76, 0.83, 0.86, 0.8], text_size=textsize,
font_size='50sp')
button1.on_release = self.add_all_images
self.steps.add_widget(button1)
def add_all_images(self):
img_pop = imgpopupall()
title = "Sequence View"
if len(self.image_list)==0:
text_no_image ="There are no images associated with the steps"
else:
text_no_image = ""
img_pop.set_text( title, text_no_image)
imagepath = "Lessons/Lesson" + str(self.lessonid) + "/images/"
for i in range(len(self.image_list)):
if self.image_list[i] is not None and self.image_list[i] != "":
step_image = Image(source = imagepath+self.image_list[i],size=(200,200))
animation = Animation(size_hint = (0.3,0.3), t='in_quad')
animation += Animation(size_hint=(1, 1), t='in_quad')
if (i < 4):
img_pop.all_images1.add_widget(step_image)
animation.start(step_image)
else:
img_pop.all_images2.add_widget(step_image)
animation.start(step_image)
img_pop.open()
def add_image(self,instance,a,*args):
print(a)
print(instance)
if a < len(self.button_list)-1:
button = self.button_list[a+1]
button.disabled = False
imagepath = "Lessons/Lesson" + str(self.lessonid) + "/images/"
if (self.image_list[a] != None and self.image_list[a].strip() != ""):
# image = Image(source=imagepath+self.image_list[a],size_hint_y=None,size=(400,400))
# self.images.add_widget(image)
self.text_image = imagepath+self.image_list[a]
text_no_image = ""
else:
self.text_image = "trans.png"
text_no_image = "No Image Associated with this step"
img_pop = imgpopup()
img_pop.set_text(self.text_image,self.step_list[a],text_no_image)
img_pop.open()
sound_speak = Thread(target=data_lessons.playtextsound, args=(self.step_list[a],))
sound_speak.start()
class LessonWhiteboardScreen(Screen):
text_image_1 = StringProperty()
font_name = StringProperty("Caveat-Bold.ttf")
def __init__(self,**kwargs):
super(LessonWhiteboardScreen,self).__init__(**kwargs)
Window.bind(on_keyboard=self.on_key)
def on_enter(self, *args):
self.font_name = self.manager.get_font()
self.lessonid = self.manager.get_screen('lessons').selected_lesson
self.filename_pfix = "Lessons" + os.path.sep + "Lesson" + str(
self.lessonid) + os.path.sep + "images" + os.path.sep
filename = data_capture_lessons.get_whiteboard_image(self.lessonid)
if filename is not None and filename != "":
self.text_image_1 = self.filename_pfix+filename
else:
self.text_image_1 = "placeholder.png"
def set_next_screen(self):
if self.manager.current == 'whiteboard':
self.manager.transition.direction = 'left'
self.manager.current = self.manager.next()
def set_previous_screen(self):
if self.manager.current == 'whiteboard':
self.manager.transition.direction = 'right'
self.manager.current = self.manager.previous()
def on_key(self, window, key, *args):
if key == 27: # the esc key
if self.manager.current == 'whiteboard':
self.manager.transition.direction = 'right'
self.manager.current = 'factual'
return True
class LessonNotesScreen(Screen):
text_label_1 = StringProperty()
font_name = StringProperty("Caveat-Bold.ttf")
def __init__(self, **kwargs):
super(LessonNotesScreen, self).__init__(**kwargs)
Window.bind(on_keyboard=self.on_key)
def on_key(self, window, key, *args):
if key == 27: # the esc key
if self.manager.current == 'notes':
self.manager.transition.direction = 'right'
self.manager.current = 'whiteboard'
return True
def on_enter(self):
self.font_name = self.manager.get_font()
self.lessonid = self.manager.get_screen('lessons').selected_lesson
txt_notes = data_capture_lessons.get_notes(self.lessonid)
if (txt_notes is None):
self.text_label_1 = ""
else:
self.text_label_1 = txt_notes
def set_next_screen(self):
if self.manager.current == 'notes':
self.manager.transition.direction = 'left'
self.manager.current = 'apply'
def set_previous_screen(self):
if self.manager.current == 'notes':
self.manager.transition.direction = 'right'
self.manager.current = 'whiteboard'
class LessonAssessScreen(Screen):
text_label_1 = StringProperty()
text_label_2 = StringProperty()
font_name = StringProperty("Caveat-Bold.ttf")
steps = ObjectProperty(None)
def __init__(self, **kwargs):
super(LessonAssessScreen, self).__init__(**kwargs)
Window.bind(on_keyboard=self.on_key)
def on_key(self, window, key, *args):
if key == 27: # the esc key
if self.manager.current == 'assess':
self.manager.transition.direction = 'right'
self.manager.current = 'apply'
return True
def on_enter(self):
self.font_name = self.manager.get_font()
self.lessonid = self.manager.get_screen('lessons').selected_lesson
self.text_label_1, self.text_label_2 = data_capture_lessons.get_questions_answer(self.lessonid)
self.formlink = data_capture_lessons.get_formlink(self.lessonid)
if self.formlink is not None and self.formlink != "" and hasattr(self,"form_button") == False:
self.form_button = Button(text="Launch External Link",size_hint=(1,0.1),background_color = [0.76,0.83,0.86,0.8],
on_release = self.launch_form)
self.ids.assess.add_widget(self.form_button)
def launch_form(self,*args):
webbrowser.open(self.formlink)
def on_assess_text(self, wid, text):
if text is not None and len(text) > 0 and text[-1] == " " and self.manager.get_lang() != "English":
text = text.strip()
output = transliterate(text, sanscript.HK, sanscript.DEVANAGARI)
output = output + " "
wid.text = output
def on_save(self):
ret = data_capture_lessons.set_answer(self.lessonid,self.text_label_2)
print(self.text_label_2)
print(str(ret))
def on_share(self):
Clipboard.copy(self.text_label_2)
def set_next_screen(self):
if self.manager.current == 'assess':
self.manager.transition.direction = 'left'
self.manager.current = 'groups'
def set_previous_screen(self):
if self.manager.current == 'assess':
self.manager.transition.direction = 'right'
self.manager.current = 'apply'
class Popups(BoxLayout):
pass
class ScreenManagement(ScreenManager):
lesson_font = StringProperty()
def set_font(self, text):
self.lesson_font = text
def get_font(self):
return self.lesson_font
def set_lang(self, text):
self.lesson_lang = text
def get_lang(self):
return self.lesson_lang
class MagicRoomApp(App):
def on_pause(self):
return True
def build(self):
self.icon = 'logo_bg_small.png'
self.title = 'Learning Room'
return ScreenManagement()
#from jnius import autoclass, cast
MagicRoomApp().run()