Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from kivy.core.audio import SoundLoader
- from kivy.factory import Factory
- from kivy.core.window import Window
- from kivy.properties import StringProperty, ObjectProperty,ListProperty
- from kivy.uix.label import Label
- from kivy.uix.button import Button
- from kivy.uix.popup import Popup
- from kivy.uix.screenmanager import ScreenManager, Screen,WipeTransition,RiseInTransition
- from kivy.uix.widget import Widget
- from kivymd.app import MDApp
- from kivymd.uix.button import MDFlatButton
- from kivymd.uix.dialog import MDDialog
- from kivymd.uix.menu import MDDropdownMenu
- from kivymd.uix.picker import MDThemePicker
- from kivymd.toast import toast
- from kivy.animation import Animation
- from kivy.clock import Clock
- from kivy.uix.recycleview import RecycleView
- from kivymd.uix.list import TwoLineAvatarIconListItem
- from kivy.uix.behaviors import ToggleButtonBehavior
- from kivy.uix.image import Image
- from kivy.uix.scrollview import ScrollView
- Window.size=470,700
- kvm="""
- #:import Factory kivy.factory.Factory
- ScreenManager:
- HomeScreen:
- <Searchin>:
- name:'serchscreen'
- MDBoxLayout:
- orientation: 'vertical'
- spacing: 1
- md_bg_color:1,.5,0,.2
- BoxLayout:
- size_hint_y: 1/5
- canvas.before:
- Color:
- rgba: 0,0,0,1
- Rectangle:
- pos: self.pos
- size: self.size[0], 2
- MDIconButton:
- icon: 'home'
- size_hint_y: 1
- on_press:root.manager.current='home'
- font_size:90
- color:app.theme_cls.primary_color
- MDTextField:
- id: Searchtext
- multiline: False
- hint_text:'Nnoonya'
- helper_text_mode: "persistent"
- helper_text: "Search"
- on_text:recycle.search_rv(self.text)
- MDIconButton:
- icon: 'close'
- size_hint_y:1
- text_color: 1,0,0,1
- on_press:
- Searchtext.text=''
- MDBoxLayout:
- orientation: 'vertical'
- md_bg_color:1,.5,0,.2
- padding: 4
- RV:
- viewclass: 'Search_Select_Option'
- data:self.data
- id:recycle
- RecycleBoxLayout:
- #spacing: 5
- #padding : 5
- default_size: None, None
- default_size_hint: 1, None
- size_hint_y: None
- height: self.minimum_height
- orientation: 'vertical'
- <Search_Select_Option>:
- secondary_text:'Ennyimba Za Kkristo by L.S.Jevix software '
- font_size:32
- on_release:app.root.current = self.text
- IconRightWidget:
- icon: "book-open-variant"
- ImageLeftWidget
- source:'sda1.jpg'
- <TooltipMDIconButton@MDIconButton+MDTooltip>
- <HomeScreen>:
- name:'home'
- canvas.before:
- Rectangle:
- pos: self.pos
- size: self.size
- source: 'sda1.jpg'
- BoxLayout:
- orientation: 'vertical'
- size: self.size
- MDToolbar:
- title: 'ENNYIMBA ZA KKRISTO'
- left_action_items: [['sda1.jpg']]
- right_action_items: [['magnify',lambda x:root.searchrecycle(),'search'],['dots-vertical',lambda x: root.on_start(x),'options']]
- elevation: 20
- Label:
- id: label
- font_size: 70
- text: ''
- size_hint: .2,.5
- color: 1,0,0,1
- pos_hint: {'center_x': .5}
- GridLayout:
- cols: 3
- rows: 4
- padding: 25
- spacing: 10
- Button:
- text: '1'
- #size_hint: (.2,.2)
- background_color:1,1,1,0
- on_press: root.button_pressed(1)
- font_size: 60
- color: 0,0,0,.5
- Button:
- text: '2'
- background_color:1,1,1,0
- on_press: root.button_pressed(2)
- font_size: 60
- color: 0,0,0,.5
- Button:
- text: '3'
- background_color:1,1,1,0
- on_press: root.button_pressed(3)
- font_size: 60
- color: 0,0,0,.5
- Button:
- text: '4'
- background_color:1,1,1,0
- on_press: root.button_pressed(4)
- font_size: 60
- color: 0,0,0,.5
- Button:
- text: '5'
- background_color:1,1,1,0
- on_press: root.button_pressed(5)
- font_size: 60
- color: 0,0,0,.5
- Button:
- text: '6'
- background_color:1,1,1,0
- on_press: root.button_pressed(6)
- font_size: 60
- color: 0,0,0,.5
- Button:
- text: '7'
- background_color:1,1,1,0
- on_press: root.button_pressed(7)
- font_size: 60
- color: 0,0,0,.5
- Button:
- text: '8'
- background_color:1,1,1,0
- on_press: root.button_pressed(8)
- font_size: 60
- color: 0,0,0,.5
- Button:
- text: '9'
- background_color:1,1,1,0
- on_press: root.button_pressed(9)
- font_size: 60
- color: 0,0,0,.5
- Button:
- text: u'\u00AB'
- background_color:0,0,0,0
- pos_hint: {'center_x': .4}
- on_press: root.remove()
- font_size: 80
- color:1,0,0,1
- Button:
- text: '0'
- background_color:1,1,1,0
- on_press: root.button_pressed(0)
- font_size: 60
- color: 0,0,0,.5
- PageButton:
- on_release: self.go_to_page(self.text)
- text: 'GO'
- background_color:0,0,0,0
- pos_hint: {'center_x': .9}
- font_size: 70
- color: 1,0,0,1
- MDBottomAppBar:
- MDToolbar:
- type: 'bottom'
- icon: 'share'
- #mode: 'off'
- elevation: 12
- on_action_button: app.bottom()
- <Content>:
- name: 'content'
- BoxLayout:
- orientation: 'vertical'
- size: root.width, root.height
- MDToolbar:
- color: .1,1,.1,1
- title: "1.Gw'oli mutukuvu "
- left_action_items: [['sda1.jpg',lambda x: root.callback(),'home']]
- right_action_items:[['magnify',lambda x:root.searchrecycle()]]
- elevation: 20
- MDBoxLayout:
- orientation:'vertical'
- padding:5
- PlayButton:
- id:play
- size_hint:.05,.05
- adaptive_height:True
- pos_hint:{'center_x':.5,'center_y':.5}
- on_state:
- scroll.animate_scroll(self.state)
- MDCard:
- orientation:'vertical'
- md_bg_color:1,1,1,1
- elevation:70
- #height:
- padding:5
- spacing:20
- size_hint:1,.5
- radius:10,10
- AnimScrollView:
- size:self.size
- id:scroll
- effect_cls: 'ScrollEffect'
- size_hint: 1,1
- bar_width:4
- bar_color:app.theme_cls.primary_color
- MDBoxLayout:
- md_bg_color:app.theme_cls.bg_normal
- adaptive_height:True
- orientation:'vertical'
- size_hint_y:None
- height:self.minimum_height
- width:self.minimum_width
- cols:1
- padding:17
- spacing:20
- MDLabel:
- text:""
- id:labelhymn
- font_size:35
- font_name:'fonts/popins.ttf'
- adaptive_height:True
- """
- class AnimScrollView(ScrollView):
- def __init__(self, **kwargs):
- super().__init__(**kwargs)
- time=170
- self.anim = Animation(scroll_y=0, duration=time) + Animation(scroll_y=1, duration=5)
- self.anim.repeat = True
- def animate_scroll(self, toggle_state):
- if toggle_state == 'down':
- self.anim.start(self)
- else:
- self.anim.stop(self)
- class PlayButton(ToggleButtonBehavior, Image):
- def __init__(self, **kwargs):
- super(PlayButton, self).__init__(**kwargs)
- self.source = 'play icon.png'
- self.background_color=1,1,0,1
- def on_state(self, widget, value):
- if value == 'down':
- self.source = 'Pause-Button.png'
- self.sound=SoundLoader.load('piano/holy.mp3')
- self.sound.play()
- toast('playing.....')
- self.sound.loop=True
- else:
- self.source = 'play icon.png'
- toast('stoped')
- self.sound.stop()
- class RV(RecycleView):
- def on_kv_post(self, base_widget):
- self.init_data()
- def init_data(self):
- # initialize the data for the recycleview
- self.ennyimba=[
- "Gw'oli Mutukuvu","Ka Tukusuute Omulokozi Waffe ",'Mumaaso ga Yesu','Tusinze Nnyo Erinnya Lye',
- 'Tumusinze Mukama Waffe',"Mwe Amawanga Ag'oku Nsi",'Mukama Gwe Kifo kyaffe','Okukaaba Kwange Owulire',
- 'Gwe Eyanunula','Jjangu Yesu Obe Mu Nze','Bonna basuute Mukama',"Twebaza gwe omuva byonna","Yesu wasuubiza ffe abantu bo","Ka ntambule naawe Yesu",
- "Yesu alifuga wonna wonna","Nkwetaaga ayi Mukama","Si nze, naye Kristo"
- ]
- self.data = [{'text': f'{i}'} for i in self.ennyimba]
- def search_rv(self, text):
- if not text:
- self.init_data()
- else:
- self.data = [x for x in self.data if text.capitalize() in x['text']]
- class Search_Select_Option(TwoLineAvatarIconListItem):
- pass
- class Searchin(Screen,RV):
- pass
- class ScreenManager(ScreenManager):
- def __init__(self,**kwargs):
- super(screenmanager).__init__(**kwargs)
- self.transition=RiseInTransition()
- class HomeScreen(Screen):
- def on_start(self,instance):
- self.dropdown_list=[
- { "viewclass":"OneLineListItem",
- "text":"contact",
- "on_release":lambda x ="contact":self.contact_callback()
- },
- {
- "viewclass": "OneLineListItem",
- "text": "Color Theme",
- "on_release": lambda x="Color Theme": self.themeshow()
- },
- {
- "viewclass": "OneLineListItem",
- "text": "About",
- "on_release": lambda x="About": self.about_callback()
- },
- {
- "viewclass": "OneLineListItem",
- "text": "Exite",
- "on_release": lambda x="Exite": EnnyimbaApp().stop()
- },
- {
- "viewclass": "OneLineListItem",
- "text": "Close",
- "on_release": lambda x="Close": self.dropdown.dismiss()
- }
- ]
- self.dropdown=MDDropdownMenu(
- items=self.dropdown_list,
- width_mult=3,
- background_color=(1,.4,0,1),
- )
- self.dropdown.caller=instance
- self.dropdown.open()
- def themeshow(self):
- t=MDThemePicker()
- t.open()
- def contact_callback(self):
- dialog=ObjectProperty(None)
- self.dialog = MDDialog(
- title="Contact:",
- type="custom",
- size_hint=[.4,.3],
- text="Contact the developer: "
- " Email: samueljevix234@gmail.com "
- " mobile: +256754045576",
- buttons=[
- MDFlatButton(
- text="OK"
- ),
- ],
- )
- self.dialog.open()
- def about_callback(self):
- #print("about my app")
- self.dialog = MDDialog(
- title="About:",
- size_hint=[.4, .3],
- type="custom",
- text="This is Ennyimba Za Kkristo "
- " version: 2.0.0"
- " Origin:Uganda(Buganda)"
- " By Lugya samuel jevix.",
- buttons=[
- MDFlatButton(
- text="OK"
- ),
- ],
- )
- self.dialog.open()
- def theme_callback(self):
- print("theme")
- def button_pressed(self, button):
- gt5 = self.ids.label.text
- if gt5 == '0':
- self.ids.label.text = ''
- self.ids.label.text = f'{button}'
- else:
- self.ids.label.text = f'{gt5}'f'{button}'
- def remove(self):
- gt5 = self.ids.label.text
- gt5=gt5[:-1]
- self.ids.label.text=gt5
- def searchrecycle(self):
- self.manager.current='serchscreen'
- class PageButton(Button):
- hymns = {'1': {'text': "Gw'oli mutukuvu.txt", 'audio': 'piano/holy.mp3'},
- '2': {'text': 'convert kivy app.txt', 'audio': 'hymn_01.mp3'},
- '3': {'text': 'hymn_02.txt', 'audio': 'hymn_02.mp3'},
- '4': {'text': 'hymn_03.txt', 'audio': 'hymn_03.mp3'},
- '5': {'text': 'hymn_04.txt', 'audio': 'hymn_04.mp3'},
- '6': {'text': 'hymn_05.txt', 'audio': 'hymn_05.mp3'},
- '7': {'text': 'hymn_06.txt', 'audio': 'hymn_06.mp3'},
- '8': {'text': 'hymn_07.txt', 'audio': 'hymn_07.mp3'},
- '9': {'text': 'hymn_08.txt', 'audio': 'hymn_08.mp3'},
- '10': {'text': 'hymn_09.txt', 'audio': 'hymn_09.mp3'},
- '11': {'text': 'hymn_10.txt', 'audio': 'hymn_10.mp3'},
- '12': {'text': 'hymn_11.txt', 'audio': 'hymn_11.mp3'},
- '13': {'text': 'hymn_12.txt', 'audio': 'hymn_12.mp3'},
- '14': {'text': 'hymn_13.txt', 'audio': 'hymn_13.mp3'},
- '15': {'text': 'hymn_14.txt', 'audio': 'hymn_14.mp3'},
- '16': {'text': 'hymn_15.txt', 'audio': 'hymn_15.mp3'}}
- def get_hymn_text(self, page):
- with open(self.hymns[page]['text']) as f:
- return f.read()
- def go_to_page(self, page):
- app = MDApp.get_running_app()
- self.manager.get_screen('contents').ids.labelhymn.text = self.get_hymn_text(page)
- self.manager.current = 'contents'
- gt5 = self.ids.label.text
- page = page_name[gt5]
- try:
- pass
- except:
- self.ids.label.text="Not found"
- self.ids.label.text=""
- class Content(Screen):
- def searchrecycle(self):
- self.manager.current='serchscreen'
- if self.ids.play.state=='down':
- self.ids.play.sound.stop()
- self.ids.play.source = 'play icon.png'
- def callback(self):
- self.manager.current=(str(0))
- if self.ids.play.state=='down':
- self.ids.play.sound.stop()
- self.ids.play.source = 'play icon.png'
- class EnnyimbaApp(MDApp):
- def __init__(self, **kwargs):
- super().__init__(**kwargs)
- self.screens = iter(
- [
- Content,Searchin
- ])
- def build(self):
- self.theme_cls.theme_style = 'Light'
- self.theme_cls.primary_palette="Amber" #['Red', 'Pink', 'Purple', 'DeepPurple', 'Indigo', 'Blue', 'LightBlue', 'Cyan', 'Teal', 'Green', 'LightGreen', 'Lime', '', 'Amber', 'Orange', 'DeepOrange', 'Brown', 'Gray', 'BlueGray']
- self.theme_cls.accent_hue='400'
- self.title='Ennyimbs za Kkristo'
- self.theme_cls.accent_palette='Amber'
- self.icon='sda1.jpg'
- Window.borderless=True
- Builder.load_string(kvm)
- def on_start(self):
- Clock.schedule_once(self.load_screens, 1)
- def load_screens(self, dt):
- for s in self.screens:
- # instance and add Screen
- self.root.add_widget(s())
- Clock.schedule_once(self.load_screens)
- print(f'Screen {s} loaded')
- return
- def bottom(self):
- print('bottom')
- EnnyimbaApp().run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement