Advertisement
jevixlugya

main.py

Nov 11th, 2022
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 15.43 KB | None | 0 0
  1. from kivy.core.audio import SoundLoader
  2. from kivy.factory import Factory
  3. from kivy.core.window import Window
  4. from kivy.properties import StringProperty, ObjectProperty
  5. from kivy.uix.label import Label
  6. from kivy.uix.popup import Popup
  7. from kivy.uix.screenmanager import ScreenManager, Screen,WipeTransition,RiseInTransition
  8. from kivy.uix.widget import Widget
  9. from kivymd.app import MDApp
  10. from kivymd.uix.button import MDFlatButton
  11. from kivymd.uix.dialog import MDDialog
  12. from kivymd.uix.menu import MDDropdownMenu
  13. from kivymd.uix.picker import MDThemePicker
  14. from kivymd.uix.boxlayout import MDBoxLayout
  15. from kivymd.uix.bottomsheet import MDListBottomSheet
  16. from kivymd.toast import toast
  17. from kivy.animation import Animation
  18. import os
  19. from kivy.clock import Clock
  20. from kivy.uix.recycleview import RecycleView
  21. from kivymd.uix.list import TwoLineAvatarIconListItem
  22. from kivy.properties import ListProperty
  23. from kivymd.uix.textfield import MDTextField
  24. from kivy.uix.behaviors import ToggleButtonBehavior
  25. from kivy.uix.image import Image
  26. from kivy.uix.scrollview import ScrollView
  27. Window.size=470,700
  28.  
  29. class AnimScrollView(ScrollView):
  30.     def __init__(self, **kwargs):
  31.         super().__init__(**kwargs)
  32.         time=170
  33.         self.anim = Animation(scroll_y=0, duration=time) + Animation(scroll_y=1, duration=5)
  34.         self.anim.repeat = True
  35.  
  36.     def animate_scroll(self, toggle_state):
  37.         if toggle_state == 'down':
  38.             self.anim.start(self)
  39.         else:
  40.             self.anim.stop(self)
  41. class PlayButton(ToggleButtonBehavior, Image):
  42.     def __init__(self, **kwargs):
  43.         super(PlayButton, self).__init__(**kwargs)    
  44.         self.source = 'play icon.png'
  45.         self.background_color=1,1,0,1
  46.  
  47.  
  48.     def on_state(self, widget, value):
  49.         if value == 'down':
  50.             self.source = 'Pause-Button.png'
  51.             self.sound=SoundLoader.load('piano/holy.mp3')
  52.             self.sound.play()
  53.             toast('playing.....')
  54.             #self.sound.loop=True
  55.         else:
  56.             self.source = 'play icon.png'
  57.             toast('stoped')
  58.             self.sound.stop()
  59.  
  60.  
  61. class PlayButton2(ToggleButtonBehavior, Image):
  62.     def __init__(self, **kwargs):
  63.         super(PlayButton2, self).__init__(**kwargs)    
  64.         self.source = 'play icon.png'
  65.         self.background_color=1,1,0,1
  66.  
  67.     def on_state(self, widget, value):
  68.         if value == 'down':
  69.             self.source = 'Pause-Button.png'
  70.             self.sound=SoundLoader.load('piano/katukusute.mp3')
  71.             self.sound.play()
  72.             toast('playing.....')
  73.         else:
  74.             self.source = 'play icon.png'
  75.             toast('stoped')
  76.             self.sound.stop()
  77.  
  78. class PlayButton3(ToggleButtonBehavior, Image):
  79.     def __init__(self, **kwargs):
  80.         super(PlayButton3, self).__init__(**kwargs)    
  81.         self.source = 'play icon.png'
  82.         self.background_color=1,1,0,1
  83.  
  84.     def on_state(self, widget, value):
  85.         if value == 'down':
  86.             self.source = 'Pause-Button.png'
  87.             self.sound=SoundLoader.load('piano/mumaaso ga yesu.mp3')
  88.             self.sound.play()
  89.             toast('playing.....')
  90.         else:
  91.             self.source = 'play icon.png'
  92.             toast('stoped')
  93.             self.sound.stop()
  94.  
  95. class PlayButton4(ToggleButtonBehavior, Image):
  96.     def __init__(self, **kwargs):
  97.         super(PlayButton4, self).__init__(**kwargs)    
  98.         self.source = 'play icon.png'
  99.         self.background_color=1,1,0,1
  100.  
  101.     def on_state(self, widget, value):
  102.         if value == 'down':
  103.             self.source = 'Pause-Button.png'
  104.             self.sound=SoundLoader.load('piano/4.mp3')
  105.             self.sound.play()
  106.             toast('playing.....')
  107.         else:
  108.             self.source = 'play icon.png'
  109.             toast('stoped')
  110.             self.sound.stop()
  111.  
  112.  
  113. class RV(RecycleView):
  114.     def on_kv_post(self, base_widget):
  115.         self.init_data()
  116.  
  117.     def init_data(self):
  118.         # initialize the data for the recycleview
  119.         self.ennyimba=[
  120.             "Gw'oli Mutukuvu","Ka Tukusuute Omulokozi Waffe ",'Mumaaso ga Yesu','Tusinze Nnyo Erinnya Lye',
  121.             'Tumusinze Mukama Waffe',"Mwe Amawanga Ag'oku Nsi",'Mukama Gwe Kifo kyaffe','Okukaaba Kwange Owulire',
  122.             'Gwe Eyanunula','Jjangu Yesu Obe Mu Nze','Bonna basuute Mukama',"Twebaza gwe omuva byonna","Yesu wasuubiza ffe abantu bo","Ka ntambule naawe Yesu",
  123.             "Yesu alifuga wonna wonna","Nkwetaaga ayi Mukama","Si nze, naye Kristo"
  124.            
  125.            
  126.            
  127.            
  128.            
  129.            
  130.            
  131.         ]
  132.         self.data = [{'text': f'{i}'} for i in self.ennyimba]
  133.  
  134.     def search_rv(self, text):
  135.         if not text:
  136.             self.init_data()
  137.         else:
  138.             self.data = [x for x in self.data if text in x['text']]
  139.        
  140. class Search_Select_Option(TwoLineAvatarIconListItem):
  141.    
  142.     pass
  143.  
  144. class Searchin(Screen,RV):
  145.  
  146.     pass
  147. class ScreenManager(ScreenManager):
  148.     def __init__(self,**kwargs):
  149.         super(screenmanager).__init__(**kwargs)
  150.         self.transition=RiseInTransition()
  151.    
  152.    
  153.  
  154.  
  155. class HomeScreen(Screen):
  156.  
  157.  
  158.     def on_start(self,instance):
  159.  
  160.         self.dropdown_list=[
  161.             {   "viewclass":"OneLineListItem",
  162.                 "text":"contact",
  163.                 "on_release":lambda x ="contact":self.contact_callback()
  164.             },
  165.  
  166.  
  167.             {
  168.                 "viewclass": "OneLineListItem",
  169.                 "text": "Color Theme",
  170.                 "on_release": lambda x="Color Theme": self.themeshow()
  171.  
  172.             },
  173.             {
  174.                 "viewclass": "OneLineListItem",
  175.                 "text": "About",
  176.                 "on_release": lambda x="About": self.about_callback()
  177.  
  178.  
  179.             },            
  180.  
  181.             {
  182.                 "viewclass": "OneLineListItem",
  183.                 "text": "Exite",
  184.                 "on_release": lambda x="Exite": EnnyimbaApp().stop()
  185.             },
  186.  
  187.  
  188.             {
  189.                 "viewclass": "OneLineListItem",
  190.                 "text": "Close",
  191.                 "on_release": lambda x="Close": self.dropdown.dismiss()
  192.             }
  193.  
  194.  
  195.         ]
  196.         self.dropdown=MDDropdownMenu(
  197.             items=self.dropdown_list,
  198.             width_mult=3,
  199.             background_color=(1,.4,0,1),
  200.  
  201.         )
  202.         self.dropdown.caller=instance
  203.        
  204.         self.dropdown.open()
  205.    
  206.  
  207.     def themeshow(self):
  208.         t=MDThemePicker()
  209.         t.open()
  210.  
  211.  
  212.     def contact_callback(self):
  213.         dialog=ObjectProperty(None)
  214.         self.dialog = MDDialog(
  215.             title="Contact:",
  216.             type="custom",
  217.             size_hint=[.4,.3],
  218.             text="Contact the developer:                           "
  219.             " Email: samueljevix234@gmail.com                      "
  220.             " mobile: +256754045576",
  221.             buttons=[
  222.  
  223.                 MDFlatButton(
  224.                     text="OK"
  225.                 ),
  226.             ],
  227.         )
  228.         self.dialog.open()
  229.  
  230.     def about_callback(self):
  231.         #print("about my app")
  232.  
  233.  
  234.         self.dialog = MDDialog(
  235.             title="About:",
  236.             size_hint=[.4, .3],
  237.             type="custom",
  238.             text="This is Ennyimba Za Kkristo "
  239.             " version: 2.0.0"
  240.             " Origin:Uganda(Buganda)"
  241.             " By Lugya samuel jevix.",
  242.             buttons=[
  243.  
  244.                 MDFlatButton(
  245.                     text="OK"
  246.                 ),
  247.             ],
  248.         )
  249.         self.dialog.open()
  250.  
  251.     def theme_callback(self):
  252.         print("theme")
  253.     def button_pressed(self, button):
  254.         gt5 = self.ids.label.text
  255.  
  256.  
  257.  
  258.         if gt5 == '0':
  259.             self.ids.label.text = ''
  260.             self.ids.label.text = f'{button}'
  261.  
  262.         else:
  263.             self.ids.label.text = f'{gt5}'f'{button}'
  264.  
  265.     def go_button(self):
  266.         gt5 = self.ids.label.text
  267.         try:
  268.             if self.ids.label.text=='1':
  269.                 self.manager.current="Gw'oli Mutukuvu"
  270.             if self.ids.label.text=='2':
  271.                 self.manager.current="Ka Tukusuute Omulokozi Waffe "
  272.             if self.ids.label.text=='3':
  273.                 self.manager.current="Mumaaso ga Yesu"
  274.             if self.ids.label.text=='4':
  275.                 self.manager.current="Tusinze Nnyo Erinnya Lye"
  276.             if self.ids.label.text=='5':
  277.                 self.manager.current="Tumusinze Mukama Waffe"            
  278.             if self.ids.label.text=='6':
  279.                 self.manager.current="Mwe Amawanga Ag'oku Nsi"
  280.             if self.ids.label.text=='7':
  281.                 self.manager.current='Mukama Gwe Kifo kyaffe'
  282.             if self.ids.label.text=='8':
  283.                 self.manager.current="Okukaaba Kwange Owulire"
  284.             if self.ids.label.text=='9':
  285.                 self.manager.current="Gwe Eyanunula"
  286.             if self.ids.label.text=='10':
  287.                 self.manager.current="Jjangu Yesu Obe Mu Nze"
  288.             if self.ids.label.text=='11':
  289.                 self.manager.current="Bonna basuute Mukama"
  290.             if self.ids.label.text=='12':
  291.                 self.manager.current="Twebaza gwe omuva byonna"
  292.             if self.ids.label.text=='13':
  293.                 self.manager.current="Yesu wasuubiza ffe abantu bo"
  294.             if self.ids.label.text=='14':
  295.                 self.manager.current="Ka ntambule naawe Yesu"
  296.             if self.ids.label.text=='15':
  297.                 self.manager.current="Yesu alifuga wonna wonna"
  298.  
  299.             if self.ids.label.text=='16':
  300.                 self.manager.current="Nkwetaaga ayi Mukama"
  301.             if self.ids.label.text=='17':
  302.                 self.manager.current="Si nze, naye Kristo"
  303.  
  304.         except:
  305.             self.ids.label.text="Not found"
  306.             self.ids.label.text=""
  307.  
  308.  
  309.     def remove(self):
  310.          gt5 = self.ids.label.text
  311.          gt5=gt5[:-1]
  312.          self.ids.label.text=gt5
  313.      
  314.     def searchrecycle(self):
  315.         self.manager.current='searchscreen'
  316.  
  317.  
  318.  
  319. class MainInterface1(Screen):
  320.     def searchrecycle(self):
  321.         self.manager.current='searchscreen'
  322.         if self.ids.play.state=='down':
  323.             self.ids.play.sound.stop()
  324.             self.ids.play.source = 'play icon.png'            
  325.     def callback(self):
  326.         self.manager.current=(str(0))
  327.         if self.ids.play.state=='down':
  328.             self.ids.play.sound.stop()
  329.             self.ids.play.source = 'play icon.png'
  330.                        
  331. class MainInterface2(Screen):
  332.     def searchrecycle(self):
  333.         self.manager.current='searchscreen'
  334.         if self.ids.play2.state=='down':
  335.             self.ids.play2.sound.stop()
  336.             self.ids.play2.source = 'play icon.png'        
  337.     def callback(self):
  338.         self.manager.current=(str(0))
  339.         if self.ids.play2.state=='down':
  340.             self.ids.play2.sound.stop()
  341.             self.ids.play2.source = 'play icon.png'
  342.            
  343.  
  344. class MainInterface3(Screen):
  345.     def searchrecycle(self):
  346.         self.manager.current='searchscreen'
  347.         if self.ids.play3.state=='down':
  348.             self.ids.play3.sound.stop()
  349.             self.ids.play3.source = 'play icon.png'            
  350.     def callback(self):
  351.         self.manager.current=(str(0))
  352.         if self.ids.play3.state=='down':
  353.             self.ids.play3.sound.stop()
  354.             self.ids.play3.source = 'play icon.png'
  355.  
  356.  
  357.  
  358. class MainInterface4(Screen):
  359.     def searchrecycle(self):
  360.         self.manager.current='searchscreen'
  361.         if self.ids.play4.state=='down':
  362.             self.ids.play4.sound.stop()
  363.             self.ids.play4.source = 'play icon.png'        
  364.     def callback(self):
  365.         self.manager.current=(str(0))
  366.  
  367.         if self.ids.play4.state=='down':
  368.             self.ids.play4.sound.stop()
  369.             self.ids.play4.source = 'play icon.png'      
  370.  
  371.  
  372.  
  373. class MainInterface5(Screen):
  374.     def searchrecycle(self):
  375.         self.manager.current='searchscreen'
  376.     def callback(self):
  377.         self.manager.current=(str(0))
  378.          
  379.  
  380.  
  381.  
  382. class MainInterface6(Screen):
  383.     def searchrecycle(self):
  384.         self.manager.current='searchscreen'
  385.     def callback(self):
  386.         self.manager.current=(str(0))
  387.  
  388.          
  389.  
  390.  
  391.  
  392. class MainInterface7(Screen):
  393.     def searchrecycle(self):
  394.         self.manager.current='searchscreen'
  395.     def callback(self):
  396.         self.manager.current=(str(0))  
  397.          
  398.  
  399.  
  400.  
  401. class MainInterface8(Screen):
  402.  
  403.     def searchrecycle(self):
  404.         self.manager.current='searchscreen'
  405.          
  406.     def callback(self):
  407.         self.manager.current=(str(0))
  408.  
  409.  
  410. class MainInterface9(Screen):
  411.     def searchrecycle(self):
  412.         self.manager.current='searchscreen'
  413.          
  414.     def callback(self):
  415.         self.manager.current=(str(0))
  416.  
  417.  
  418. class MainInterface10(Screen):
  419.     def searchrecycle(self):
  420.         self.manager.current='searchscreen'
  421.          
  422.     def callback(self):
  423.         self.manager.current=(str(0))
  424.  
  425. class MainInterface11(Screen):
  426.     def searchrecycle(self):
  427.         self.manager.current='searchscreen'
  428.          
  429.     def callback(self):
  430.         self.manager.current=(str(0))
  431.  
  432. class MainInterface12(Screen):
  433.     def searchrecycle(self):
  434.         self.manager.current='searchscreen'
  435.          
  436.     def callback(self):
  437.         self.manager.current=(str(0))
  438.  
  439. class MainInterface13(Screen):
  440.     def searchrecycle(self):
  441.         self.manager.current='searchscreen'
  442.          
  443.     def callback(self):
  444.         self.manager.current=(str(0))
  445.  
  446. class MainInterface14(Screen):
  447.     def searchrecycle(self):
  448.         self.manager.current='searchscreen'
  449.          
  450.     def callback(self):
  451.         self.manager.current=(str(0))
  452.  
  453. class MainInterface15(Screen):
  454.     def searchrecycle(self):
  455.         self.manager.current='searchscreen'
  456.          
  457.     def callback(self):
  458.         self.manager.current=(str(0))
  459.  
  460.  
  461. class MainInterface16(Screen):
  462.     def searchrecycle(self):
  463.         self.manager.current='searchscreen'
  464.          
  465.     def callback(self):
  466.         self.manager.current=(str(0))
  467.  
  468.  
  469. class MainInterface17(Screen):
  470.     def searchrecycle(self):
  471.         self.manager.current='searchscreen'
  472.          
  473.     def callback(self):
  474.         self.manager.current=(str(0))
  475.  
  476. class EnnyimbaApp(MDApp):
  477.     def __init__(self, **kwargs):
  478.         super().__init__(**kwargs)
  479.         self.screens = iter(
  480.             [
  481.                 MainInterface1, MainInterface2, MainInterface3, MainInterface4, MainInterface5, MainInterface6, MainInterface7,
  482.                 MainInterface8,MainInterface9,MainInterface10,Searchin,MainInterface11,MainInterface12,MainInterface13,MainInterface14,MainInterface15,MainInterface16,
  483.                 MainInterface17
  484.  
  485.  
  486.  
  487.  
  488.  
  489.  
  490.  
  491.             ])
  492.  
  493.     def build(self):
  494.         self.theme_cls.theme_style = 'Light'
  495.         self.theme_cls.primary_palette="Amber" #['Red', 'Pink', 'Purple', 'DeepPurple', 'Indigo', 'Blue', 'LightBlue', 'Cyan', 'Teal', 'Green', 'LightGreen', 'Lime', '', 'Amber', 'Orange', 'DeepOrange', 'Brown', 'Gray', 'BlueGray']
  496.         self.theme_cls.accent_hue='400'
  497.         self.title='Ennyimbs za Kkristo'
  498.         self.theme_cls.accent_palette='Amber'
  499.         self.icon='sda1.jpg'
  500.         Window.borderless=True
  501.  
  502.     def on_start(self):
  503.         Clock.schedule_once(self.load_screens, 1)
  504.  
  505.     def load_screens(self, dt):
  506.         for s in self.screens:
  507.             # instance and add Screen
  508.             self.root.add_widget(s())
  509.             Clock.schedule_once(self.load_screens)
  510.             print(f'Screen {s} loaded')
  511.             return
  512.  
  513.     def bottom(self):
  514.         print('bottom')
  515.        
  516.  
  517. EnnyimbaApp().run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement