-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
907 lines (832 loc) · 31.1 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
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition, SlideTransition
from kivy.lang import Builder
from kivy.uix.button import ButtonBehavior, Button
from kivy.uix.image import Image
# from kivy.core.window import Window
from kivy.factory import Factory
from kivy.animation import Animation
from kivy.properties import ObjectProperty, NumericProperty
from kivy.core.audio import SoundLoader, Sound
from kivy.clock import Clock
from kivy.storage.jsonstore import JsonStore
from kivy.storage.dictstore import DictStore
import random
from os.path import join
from kivy import kivy_home_dir
# Window.size = (1080, 1920)
# dict lists ----------------------------------------------------------------
ani_dicts = {1: 'DOG', 2: 'COW', 3: 'CAT', 4: 'BEE', 5: 'OWL', 6: 'RAT', 7: 'PIG', 8: 'FOX', 9: 'BAT', 10: 'LION', 11: 'WOLF', 12: 'GOAT', 13: 'DEER', 14: 'FROG', 15: 'PANDA', 16: 'SEAL', 17: 'ORCA', 18: 'DOVE', 19: 'CROW', 20: 'ANTS', 21: 'ZEBRA', 22: 'SHEEP', 23: 'HORSE', 24: 'TIGER', 25: 'SNAKE', 26: 'OTTER', 27: 'CAMEL', 28: 'DONKEY', 29: 'CHEETAH', 30: 'SWAN', 31: 'HYENA', 32: 'LLAMA', 33: 'PARROT', 34: 'BISON', 35: 'RABBIT', 36: 'EAGLE', 37: 'GOOSE', 38: 'JACKAL', 39: 'PIGEON', 40: 'GORILLA', 41: 'GIRAFFE', 42: 'JAGUAR', 43: 'WALRUS', 44: 'COYOTE', 45: 'BEAVER', 46: 'BUFFALO', 47: 'COUGAR', 48: 'WOMBAT', 49: 'SPIDER', 50: 'DOLPHIN', 51: 'LEOPARD', 52: 'GOPHER', 53: 'MONKEY', 54: 'ELEPHANT', 55: 'PEACOCK', 56: 'RACCOON', 57: 'PENGUIN', 58: 'OSTRICH', 59: 'MEERKAT', 60: 'SPARROW', 61: 'PANTHER', 62: 'PORCUPINE', 63: 'REDPANDA', 64: 'SQUIRREL', 65: 'OPOSSUM', 66: 'CROCODILE', 67: 'CHIPMUNK', 68: 'POLARBEAR', 69: 'ARMADILLO', 70: 'ANACONDA', 71: 'KANGAROO', 72: 'BLACKBEAR', 73: 'CHIMPANZEE', 74: 'MONGOOSE', 75: 'RHINOCEROS', 76: 'GRIZZLYBEAR', 77: 'HEDGEHOG', 78: 'KOALABEAR', 79: 'ORANGUTAN', 80: 'HIPPOPOTAMUS', 81: 'HUMPBACKWHALE', 82: 'SCIMITARORYX'}
fru_dicts = {1: 'LIME', 2: 'MANGO', 3: 'FIG', 4: 'PEAR', 5: 'GUAVA', 6: 'PLUM', 7: 'PEACH', 8: 'YUZU', 9: 'APPLE',
10: 'PAPAYA', 11: 'ORANGE', 12: 'LEMON', 13: 'BANANA', 14: 'GRAPES', 15: 'DURIAN', 16: 'CHERRY',
17: 'COCONUT', 18: 'QUINCE', 19: 'APRICOT', 20: 'SOURSOP', 21: 'CUCUMBER', 22: 'AVOCADO', 23: 'TAMARIND',
24: 'PINEAPPLE', 25: 'WATERMELON', 26: 'STARFRUIT', 27: 'JACKFRUIT', 28: 'STRAWBERRY', 29: 'KIWIFRUIT',
30: 'RASPBERRY', 31: 'GRAPEFRUIT', 32: 'BLUEBERRY', 33: 'PASSIONFRUIT', 34: 'BLACKBERRY', 35: 'PERSIMMON',
36: 'PINEBERRY', 37: 'MULBERRY', 38: 'KUMQUAT', 39: 'GOOSEBERRY', 40: 'DRAGONFRUIT'}
veg_dicts = {1: 'PEAS', 2: 'TOMATO', 3: 'CORN', 4: 'MINT', 5: 'YAM', 6: 'CHIVE', 7: 'CHILLY', 8: 'BEAN', 9: 'TARO',
10: 'KALE', 11: 'GINGER', 12: 'GARLIC', 13: 'LEEK', 14: 'POTATO', 15: 'ONION', 16: 'TURNIP', 17: 'CELERY',
18: 'CABBAGE', 19: 'SPINACH', 20: 'CARROT', 21: 'LETTUCE', 22: 'PUMPKIN', 23: 'PARSNIP', 24: 'CUCUMBER',
25: 'EGGPLANT', 26: 'SQUASH', 27: 'CAPSICUM', 28: 'BROCCOLI', 29: 'BEETROOT', 30: 'SWEETPOTATO',
31: 'WHITERADISH', 32: 'CORIANDER', 33: 'CHAYOTE', 34: 'CAULIFLOWER', 35: 'MUSHROOM', 36: 'GREENONION',
37: 'RADICCHIO', 38: 'REDRADISH', 39: 'BITTERGOURD', 40: 'ARTICHOKE', 41: 'BRUSSELSPROUT', 42: 'ZUCCHINI'}
# dict list end -------------------------------------------------------------
adicts = ani_dicts
# this is to save dicts------------------------------------------------------
user_data_dir = App().user_data_dir
savedict = DictStore(join(user_data_dir, "SavedState"))
if savedict.exists('ani_d'):
svd_anilst = savedict.get('ani_d')['ani_dicts']
else:
savedict.put('ani_d', ani_dicts=1)
svd_anilst = 1
if savedict.exists('fru_d'):
svd_frulst = savedict.get('fru_d')['fru_dicts']
else:
savedict.put('fru_d', fru_dicts=1)
svd_frulst = 1
if savedict.exists('veg_d'):
svd_veglst = savedict.get('veg_d')['veg_dicts']
else:
savedict.put('veg_d', veg_dicts=1)
svd_veglst = 1
#print(svd_anilst,svd_frulst,svd_veglst)
# save dicts end ------------------------------------------------------------
start_list = 1
# sounds --------------------------------------------------------------------
sound = SoundLoader.load('spellebg.wav')
butaud = SoundLoader.load('butaud.wav')
fail = SoundLoader.load('fail.wav')
success = SoundLoader.load('succss.wav')
sound.loop = True
sound.state = 'stop'
fail.volume = 0
success.volume = 0
fail.play()
success.play()
# sounds end ----------------------------------------------------------------
class Home(ScreenManager):
data = ObjectProperty(None)
pass
# st screen start ----------------------------------------------------------------
class StSc(Screen):
def __init__(self, **kwargs):
super(StSc, self).__init__(**kwargs)
Clock.schedule_once(self.on_start)
def on_start(self, *args):
global sound
self.ids.imid.size = 0, 0
animation = Animation(size=(100, 100), t='out_bounce')
sound.play()
animation.start(self.ids.imid)
if self.manager.current != "FirstSc":
Clock.schedule_once(self.callbackfun, 1)
def callbackfun(self, dt):
# print(self.manager.current)
# print(self.manager.next())
self.manager.current = self.manager.next()
# st screen end -------------------------------------------------------------------
# 1st screen start ----------------------------------------------------------------
class FirstSc(Screen):
def on_pre_enter(self, *args):
# print('hi')
# print(savedict.get('ani_d'))
# print(savedict.get('fru_d'))
# print(savedict.get('veg_d'))
# print('hi')
global sound, success, fail, butaud, adicts, ani_dicts, fru_dicts, veg_dicts, start_list, svd_anilst, svd_frulst, svd_veglst
if sound.state == 'play':
self.ids.aa.source = 'musicon.png'
else:
self.ids.aa.source = 'musicoff.png'
if adicts == ani_dicts and svd_anilst > 1:
self.ids.acon.size_hint = (.5, 0.08)
self.ids.acon.disabled = False
elif adicts == fru_dicts and svd_frulst > 1:
self.ids.acon.size_hint = (.5, 0.08)
self.ids.acon.disabled = False
elif adicts == veg_dicts and svd_veglst > 1:
self.ids.acon.size_hint = (.5, 0.08)
self.ids.acon.disabled = False
else:
self.ids.acon.size_hint = (0, 0)
self.ids.acon.disabled = True
def audio(self):
global sound, success, fail, butaud
a = 'musicon.png'
b = 'musicoff.png'
if sound.state == 'stop':
sound.play()
fail.volume = 1
success.volume = 1
butaud.volume = 1
self.ids.aa.source = a
else:
sound.stop()
fail.volume = 0
success.volume = 0
butaud.volume = 0
self.ids.aa.source = b
def on_presStart(self):
global start_list
self.ids.ac.color = (.9, 1, .9, 1)
self.ids.ac.size_hint = .497, .277
start_list = 1
def on_relStart(self):
self.ids.ac.color = (1, 1, 1, 1)
self.ids.ac.size_hint = .5, .28
def on_presConStart(self):
global adicts, ani_dicts, fru_dicts, veg_dicts, start_list, svd_anilst, svd_frulst, svd_veglst
global start_list
self.ids.acon.color = (.9, 1, .9, 1)
self.ids.acon.size_hint = .45, .08
if adicts == ani_dicts:
start_list = svd_anilst
elif adicts == fru_dicts:
start_list = svd_frulst
elif adicts == veg_dicts:
start_list = svd_veglst
def on_relConStart(self):
global adicts, ani_dicts, fru_dicts, veg_dicts, start_list, svd_anilst, svd_frulst, svd_veglst
self.ids.acon.color = (1, 1, 1, 1)
self.ids.acon.size_hint = .5, .08
if adicts == ani_dicts:
if start_list == 83:
self.parent.current = "end"
else:
self.parent.current = "2nd"
elif adicts == fru_dicts:
if start_list == 41:
self.parent.current = "end"
else:
self.parent.current = "2nd"
elif adicts == veg_dicts:
if start_list == 43:
self.parent.current = "end"
else:
self.parent.current = "2nd"
# print('a')
# print(svd_anilst, svd_frulst, svd_veglst)
# print('a')
def soundplay(self):
global butaud
butaud.play()
# 1st screen end ----------------------------------------------------------------
# custbutt start ----------------------------------------------------------------
class ImBut(ButtonBehavior, Image):
pass
# custbutt end ------------------------------------------------------------------
# sec sc start ------------------------------------------------------------------
class SecSc(Screen):
def on_pre_enter(self, *args):
global sound, success, fail, butaud, adicts, ani_dicts, fru_dicts, veg_dicts, start_list, svd_anilst, svd_frulst, svd_veglst
self.a = start_list
self.all_dicts = adicts
self.stri = self.all_dicts[self.a]
self.normal_list = list(self.stri)
self.rand_list = list.copy(self.normal_list)
random.shuffle(self.rand_list)
self.ids.imid.source = self.stri + ".png"
px = 0
if len(self.rand_list) <= 10 and len(self.rand_list) > 4:
px = .058
elif len(self.rand_list) > 10:
px = .072
elif len(self.rand_list) == 3:
px = .225
elif len(self.rand_list) == 4:
px = .14
py = (.2, .245)[len(self.rand_list) > 10]
sy = (.1, .07)[len(self.rand_list) > 10]
sx = sy + .05
spX = .17
self.buttons = []
for i, j in enumerate(self.rand_list):
# self.buttons.append(ImBut(source='categ.png',text=j,on_press=self.o_p))
self.buttons.append(
Factory.ImButb(text=j, size_hint=(sx, sy), pos_hint={"x": px, "y": py}, on_press=self.o_p))
self.ids.grid.add_widget(self.buttons[i])
px += spX
if len(self.rand_list) <= 10:
if i == 4 and len(self.rand_list) == 6:
px = .399
py -= .11
elif i == 4 and len(self.rand_list) == 7:
px = .315
py -= .11
elif i == 4 and len(self.rand_list) == 8:
px = .2275
py -= .11
elif i == 4 and len(self.rand_list) == 9:
px = .12
py -= .11
elif i == 4 and len(self.rand_list) == 10:
px = .0559
py -= .11
else:
if i == 4 and len(self.rand_list) == 11:
px = .073
py -= .08
elif i == 4 and len(self.rand_list) == 12:
px = .073
py -= .08
elif i == 4 and len(self.rand_list) == 13:
px = .073
py -= .08
elif i == 4 and len(self.rand_list) == 14:
px = .073
py -= .08
elif i == 4 and len(self.rand_list) == 15:
px = .073
py -= .08
elif i == 9 and len(self.rand_list) == 11:
px = .412
py -= .08
elif i == 9 and len(self.rand_list) == 12:
px = .325
py -= .08
elif i == 9 and len(self.rand_list) == 13:
px = .243
py -= .08
elif i == 9 and len(self.rand_list) == 14:
px = .15
py -= .08
elif i == 9 and len(self.rand_list) == 15:
px = .072
py -= .08
if sound.state == 'play':
fail.volume = 1
success.volume = 1
butaud.volume = 1
self.ids.mon.source = 'musicon.png'
else:
self.ids.mon.source = 'musicoff.png'
fail.volume = 0
success.volume = 0
butaud.volume = 0
def ansanimate(self):
success.play()
self.ids.corr_ans.size = 0, 0
animation = Animation(size=(500, 500), t='out_bounce')
animation.start(self.ids.corr_ans)
def wr_ansanimate(self):
fail.play()
self.ids.wr_ans.size = 0, 0
animation = Animation(size=(500, 500), t='out_bounce')
animation.start(self.ids.wr_ans)
def o_p(self, instance):
a = self.ids.spltxt.text
if instance.on_press:
self.butaudi()
instance.back_color = (1, 1, 1, .7)
instance.disabled = True
self.ids.spltxt.text = a + str(instance.text)
if len(self.ids.spltxt.text) == len(self.stri):
if self.ids.spltxt.text == self.stri:
self.ansanimate()
Clock.schedule_once(self.delayy, 2)
else:
self.ids.wrbg.opacity = .9
self.wr_ansanimate()
Clock.schedule_once(self.wr_screen, 2)
def delayy(self, dt):
global sound, success, fail, butaud, adicts, ani_dicts, fru_dicts, veg_dicts, start_list, svd_anilst, svd_frulst, svd_veglst
start_list += 1
if self.all_dicts == ani_dicts:
savedict.put('ani_d', ani_dicts=start_list)
svd_anilst = start_list
elif self.all_dicts == veg_dicts:
savedict.put('veg_d', veg_dicts=start_list)
svd_veglst = start_list
elif self.all_dicts == fru_dicts:
savedict.put('fru_d', fru_dicts=start_list)
svd_frulst = start_list
# print(svd_anilst, svd_frulst, svd_veglst)
# print(savedict.get('ani_d'), savedict.get('fru_d'), savedict.get('veg_d'))
self.parent.current = "3rd"
def wr_screen(self, dt):
self.manager.transition = FadeTransition(duration=.8)
self.parent.current = "3rd"
self.manager.transition = SlideTransition(direction='left')
def on_leave(self, *args):
self.ids.spltxt.text = ''
self.ids.corr_ans.size = 0, 0
self.ids.wr_ans.size = 0, 0
self.ids.wrbg.opacity = 0
for i, j in enumerate(self.rand_list):
self.ids.grid.remove_widget(self.buttons[i])
def butloop(self):
global sound, success, fail, butaud
if sound.state == 'stop':
sound.play()
fail.volume = 1
success.volume = 1
butaud.volume = 1
self.ids.mon.source = 'musicon.png'
else:
sound.stop()
fail.volume = 0
success.volume = 0
butaud.volume = 0
self.ids.mon.source = 'musicoff.png'
def butaudi(self):
butaud.play()
# sec screen ends---------------------------------------------------------------------
# third screen starts-----------------------------------------------------------------
class ThirdSc(Screen):
def on_pre_enter(self, *args):
global sound, success, fail, butaud, adicts, ani_dicts, fru_dicts, veg_dicts, start_list, svd_anilst, svd_frulst, svd_veglst
self.a = start_list
self.all_dicts = adicts
self.stri = self.all_dicts[self.a]
self.normal_list = list(self.stri)
self.rand_list = list.copy(self.normal_list)
random.shuffle(self.rand_list)
self.ids.imid.source = self.stri + ".png"
px = 0
if len(self.rand_list) <= 10 and len(self.rand_list) > 4:
px = .058
elif len(self.rand_list) > 10:
px = .072
elif len(self.rand_list) == 3:
px = .225
elif len(self.rand_list) == 4:
px = .14
py = (.2, .245)[len(self.rand_list) > 10]
sy = (.1, .07)[len(self.rand_list) > 10]
sx = sy + .05
spX = .17
self.buttons = []
for i, j in enumerate(self.rand_list):
# self.buttons.append(ImBut(source='categ.png',text=j,on_press=self.o_p))
self.buttons.append(
Factory.ImButb(text=j, size_hint=(sx, sy), pos_hint={"x": px, "y": py}, on_press=self.o_p))
self.ids.grid.add_widget(self.buttons[i])
px += spX
if len(self.rand_list) <= 10:
if i == 4 and len(self.rand_list) == 6:
px = .399
py -= .11
elif i == 4 and len(self.rand_list) == 7:
px = .315
py -= .11
elif i == 4 and len(self.rand_list) == 8:
px = .2275
py -= .11
elif i == 4 and len(self.rand_list) == 9:
px = .12
py -= .11
elif i == 4 and len(self.rand_list) == 10:
px = .0559
py -= .11
else:
if i == 4 and len(self.rand_list) == 11:
px = .073
py -= .08
elif i == 4 and len(self.rand_list) == 12:
px = .073
py -= .08
elif i == 4 and len(self.rand_list) == 13:
px = .073
py -= .08
elif i == 4 and len(self.rand_list) == 14:
px = .073
py -= .08
elif i == 4 and len(self.rand_list) == 15:
px = .073
py -= .08
elif i == 9 and len(self.rand_list) == 11:
px = .412
py -= .08
elif i == 9 and len(self.rand_list) == 12:
px = .325
py -= .08
elif i == 9 and len(self.rand_list) == 13:
px = .243
py -= .08
elif i == 9 and len(self.rand_list) == 14:
px = .15
py -= .08
elif i == 9 and len(self.rand_list) == 15:
px = .072
py -= .08
if sound.state == 'play':
self.ids.mon.source = 'musicon.png'
fail.volume = 1
success.volume = 1
butaud.volume = 1
else:
self.ids.mon.source = 'musicoff.png'
fail.volume = 0
success.volume = 0
butaud.volume = 0
def ansanimate(self):
success.play()
self.ids.corr_ans.size = 0, 0
animation = Animation(size=(500, 500), t='out_bounce')
animation.start(self.ids.corr_ans)
def wr_ansanimate(self):
fail.play()
self.ids.wr_ans.size = 0, 0
animation = Animation(size=(500, 500), t='out_bounce')
animation.start(self.ids.wr_ans)
def o_p(self, instance):
a = self.ids.spltxt.text
if instance.on_press:
self.butaudi()
instance.back_color = (1, 1, 1, .7)
instance.disabled = True
self.ids.spltxt.text = a + str(instance.text)
if len(self.ids.spltxt.text) == len(self.stri):
if self.ids.spltxt.text == self.stri:
self.ansanimate()
Clock.schedule_once(self.delayy, 2)
else:
self.ids.wrbg.opacity = .9
self.wr_ansanimate()
Clock.schedule_once(self.wr_screen, 2)
def delayy(self, dt):
global sound, success, fail, butaud, adicts, ani_dicts, fru_dicts, veg_dicts, start_list, svd_anilst, svd_frulst, svd_veglst
start_list += 1
if self.all_dicts == ani_dicts:
savedict.put('ani_d', ani_dicts=start_list)
svd_anilst = start_list
elif self.all_dicts == veg_dicts:
savedict.put('veg_d', veg_dicts=start_list)
svd_veglst = start_list
elif self.all_dicts == fru_dicts:
savedict.put('fru_d', fru_dicts=start_list)
svd_frulst = start_list
# print(svd_anilst,svd_frulst,svd_veglst)
# print(savedict.get('ani_d'),savedict.get('fru_d'),savedict.get('veg_d'))
self.parent.current = "2nd"
def wr_screen(self, dt):
self.manager.transition = FadeTransition(duration=.8)
self.parent.current = "2nd"
self.manager.transition = SlideTransition(direction='left')
def on_leave(self, *args):
self.ids.spltxt.text = ''
self.ids.corr_ans.size = 0, 0
self.ids.wr_ans.size = 0, 0
self.ids.wrbg.opacity = 0
rembuts = self.buttons
for i, j in enumerate(self.rand_list):
self.ids.grid.remove_widget(self.buttons[i])
def butloop(self):
global sound, success, fail, butaud
if sound.state == 'stop':
sound.play()
fail.volume = 1
success.volume = 1
butaud.volume = 1
self.ids.mon.source = 'musicon.png'
else:
sound.stop()
fail.volume = 0
success.volume = 0
butaud.volume = 0
self.ids.mon.source = 'musicoff.png'
pass
def butaudi(self):
butaud.play()
# third screen ends--------------------------------------------------------------
# cat sc start ------------------------------------------------------------------
class Category(Screen):
global butaud
def gotoaniFpage(self):
global adicts
global ani_dicts
adicts = ani_dicts
self.ids.cata.color = (1, 1, 1, 1)
self.ids.cata.size_hint = .9, .11
def onpressani(self):
self.ids.cata.color = (1, 1, 2, .8)
self.ids.cata.size_hint = .8, .11
def gotoFruFpage(self):
global adicts
global ani_dicts
adicts = fru_dicts
self.ids.catb.color = (1, 1, 1, 1)
self.ids.catb.size_hint = .9, .11
def onpressfru(self):
self.ids.catb.color = (1, 1, 2, .8)
self.ids.catb.size_hint = .8, .11
def gotoVegFpage(self):
global adicts
global ani_dicts
adicts = veg_dicts
self.ids.catc.color = (1, 1, 1, 1)
self.ids.catc.size_hint = .9, .11
def onpressveg(self):
self.ids.catc.color = (1, 1, 2, .8)
self.ids.catc.size_hint = .8, .11
def butaudi(self):
global sound, success, fail, butaud
if sound.state == 'stop':
butaud.volume = 0
butaud.play()
else:
butaud.volume = 1
butaud.play()
# Cat screen ends---------------------------------------------------------------
class EndSc(Screen):
# def anim(self, instance):
# self.instance.size = (0,0)
# animation = Animation(size=(50, 50), t='out_bounce')
# animation.start(self.instance.size)
pass
# classes end ------------------------------------------------------------------
root_widget = Builder.load_string('''
#: import FadeTransition kivy.uix.screenmanager.FadeTransition
#: import SlideTransition kivy.uix.screenmanager.SlideTransition
Home:
transition: FadeTransition()
transition: SlideTransition()
StSc:
FirstSc:
SecSc:
ThirdSc:
Category:
EndSc:
<ImButb@Button>
id: imbutb
font_size: 0.65 * self.height
background_normal: ''
background_color: (0,0,0,0)
back_color: (1,0,1,1)
size_hint: (.15,.1)
canvas.before:
Color:
rgba: self.back_color
RoundedRectangle:
size: self.size
pos: self.pos
radius: (18,18)
<StSc>:
name: 'st'
FloatLayout:
canvas.before:
Rectangle:
pos: self.pos
size: self.size
source: 'bg.png'
Image:
id: imid
source:"stbg.png"
allow_stretch: True
keep_ratio: False
<FirstSc>:
name: '1st'
FloatLayout:
canvas.before:
Rectangle:
pos: self.pos
size: self.size
source: 'bg.png'
Rectangle:
pos: self.pos
size: self.size
source: 'firstframe.png'
Rectangle:
pos: self.pos
size: self.size
source: 'firstframe_low.png'
ImBut:
id: aa
pos_hint: {"x":.79,"top":.125}
source: 'musicon.png'
size_hint: .15,.08
on_press:
root.soundplay()
on_release:
root.audio()
ImBut:
id: ab
pos_hint: {"x":.06,"top":.125}
source: 'categ.png'
size_hint: .15,.08
on_press:
root.soundplay()
on_release:
app.root.current = 'category'
root.manager.transition.direction = 'right'
ImBut:
id: ac
text: ''
pos_hint: {"x":.25,"top":.58}
source: 'startplay.png'
size_hint: .5,.28
on_press:
root.soundplay()
root.on_presStart()
on_release:
root.on_relStart()
app.root.current = '2nd'
root.manager.transition.direction = 'left'
ImBut:
id: acon
pos_hint: {'center_x': .5, 'center_y': .22}
source: 'continue.png'
size_hint: .5,.08
on_press:
root.soundplay()
root.on_presConStart()
on_release:
root.on_relConStart()
root.manager.transition.direction = 'left'
<SecSc>:
name: '2nd'
FloatLayout:
canvas.before:
Rectangle:
pos: self.pos
size: self.size
source: 'bg.png'
Rectangle:
pos: self.pos
size: self.size
source: 'imgfrm.png'
Rectangle:
pos: self.pos
size: self.size
source: 'splfrm.png'
Rectangle:
pos: self.pos
size: self.size
source: 'forback.png'
Image:
id: imid
source:""
allow_stretch: True
keep_ratio: False
ImBut:
id: mon
pos_hint: {"x":.82,"top":.08}
source: ''
size_hint: .13,.07
on_press: root.butaudi()
on_release: root.butloop()
ImBut:
id: back
pos_hint: {"x":.05,"top":.08}
source: 'back.png'
size_hint: .128,.07
on_press: root.butaudi()
on_release:
app.root.current = '1st'
root.manager.transition.direction = 'right'
Label:
id: spltxt
text: ''
font_size: root.width / 10
pos_hint:{"y": -.093}
FloatLayout:
id: grid
cols:5
size_hint: (1.06,1.06)
Image:
id: corr_ans
size_hint:(None,None)
pos_hint: {'center_x': .5, 'center_y': .5}
size: 0,0
source:"welldone.png"
Image:
id: wrbg
opacity:0
source:"wrongbg.png"
Image:
id: wr_ans
size_hint:(None,None)
pos_hint: {'center_x': .5, 'center_y': .5}
size: 0,0
source:"wrans.png"
<ThirdSc>:
name: '3rd'
FloatLayout:
canvas.before:
Rectangle:
pos: self.pos
size: self.size
source: 'bg.png'
Rectangle:
pos: self.pos
size: self.size
source: 'imgfrm.png'
Rectangle:
pos: self.pos
size: self.size
source: 'splfrm.png'
Rectangle:
pos: self.pos
size: self.size
source: 'forback.png'
Image:
id: imid
source:""
allow_stretch: True
keep_ratio: False
ImBut:
id: mon
pos_hint: {"x":.82,"top":.08}
source: 'musicon.png'
size_hint: .13,.07
on_press: root.butaudi()
on_release: root.butloop()
ImBut:
id: back
pos_hint: {"x":.05,"top":.08}
source: 'back.png'
size_hint: .128,.07
on_press: root.butaudi()
on_release:
app.root.current = '1st'
root.manager.transition.direction = 'right'
Label:
id: spltxt
text: ''
font_size: root.width / 10
pos_hint:{"y": -.093}
FloatLayout:
id: grid
cols:5
size_hint: (1.06,1.06)
Image:
id: corr_ans
size_hint:(None,None)
pos_hint: {'center_x': .5, 'center_y': .5}
size: 0,0
source:"welldone.png"
Image:
id: wrbg
opacity:0
source:"wrongbg.png"
Image:
id: wr_ans
size_hint:(None,None)
pos_hint: {'center_x': .5, 'center_y': .5}
size: 0,0
source:"wrans.png"
<Category>:
name: 'category'
FloatLayout:
orientation: 'vertical'
canvas.before:
Rectangle:
pos: self.pos
size: self.size
source: 'bg.png'
ImBut:
id: cata
source: 'catsscreen_Ani.png'
size_hint:(.9,.11)
pos_hint: {'center_x': .5, 'center_y': .65}
on_press:
root.butaudi()
root.onpressani()
on_release:
root.gotoaniFpage()
app.root.current = '1st'
root.manager.transition.direction = 'left'
ImBut:
id: catb
source: 'catsscreen_Fru.png'
size_hint:(.9,.11)
pos_hint: {'center_x': .5, 'center_y': .5}
on_press:
root.butaudi()
root.onpressfru()
on_release:
root.gotoFruFpage()
app.root.current = '1st'
root.manager.transition.direction = 'left'
ImBut:
id: catc
source: 'catsscreen_Veg.png'
size_hint:(.9,.11)
pos_hint: {'center_x': .5, 'center_y': .35}
on_press:
root.butaudi()
root.onpressveg()
on_release:
root.gotoVegFpage()
app.root.current = '1st'
root.manager.transition.direction = 'left'
<EndSc>:
name: 'end'
FloatLayout:
orientation: 'vertical'
canvas.before:
Rectangle:
pos: self.pos
size: self.size
source: 'bg.png'
Image:
id: hur
source: 'hurrah.png'
pos_hint: {'center_x': .5, 'center_y': .5}
''')
class MyiApp(App):
def build(self):
return root_widget
MyiApp().run()