Advertisement
jevixlugya

Untitled

Nov 28th, 2022
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.81 KB | None | 0 0
  1. from kivy.app import App
  2. from kivy.lang import Builder
  3. from kivy.uix.screenmanager import Screen
  4. from kivy.uix.button import Button
  5.  
  6. kv = """
  7. <PageButton>:
  8.    on_release: self.go_to_page(self.text)
  9.  
  10. <TableOfContentsScreen>:
  11.    GridLayout:
  12.        id: grid
  13.        rows: 4
  14.        cols: 4
  15. <search>:
  16.    BoxLayout:
  17.        orientation: 'vertical'
  18.        BoxLayout:
  19.            padding:10
  20.            size_hint_y:1/9
  21.                      
  22.            TextInput:
  23.                multiline:False
  24.                size_hint_y: None
  25.                height: dp(48)
  26.                hint_text:'search hymn'            
  27.        
  28.        BoxLayout:
  29.            orientation: 'vertical'
  30.            Label:
  31.                text:'to search from here in recycleview,'
  32.  
  33.  
  34. <ContentScreen>:
  35.    BoxLayout:
  36.        Button:
  37.            size_hint_y: None
  38.            height: dp(48)
  39.            text: 'Home'
  40.            on_release: app.root.ids.sm.current = 'toc'
  41.            
  42.        Button:
  43.            text:'search'
  44.            on_press:app.root.ids.sm.current='search'
  45.            size_hint_y: None
  46.            height: dp(48)
  47.  
  48.    BoxLayout:
  49.        orientation: 'vertical'
  50.        Label:
  51.            id: label
  52.  
  53. BoxLayout:
  54.    orientation: 'vertical'
  55.    Label:
  56.        size_hint_y: None
  57.        height: dp(30)
  58.        text: 'Hymn Example'
  59.    ScreenManager:
  60.        id: sm
  61.        TableOfContentsScreen:
  62.            name: 'toc'
  63.        ContentScreen:
  64.            name: 'contents'
  65.  
  66.        search:
  67.            name:'search'    
  68.  
  69. """
  70.  
  71.  
  72. class PageButton(Button):
  73.     hymns = {'Hymn 1': {'text':'Put file names here','audio':'piano/holy.mp3'},  'Hymn 2': 'or put the text directly',
  74.              'Hymn 3': 'The text of hymn 3', 'Hymn 4': 'The text of hymn 4', 'Hymn 5': 'The text of hymn 5',
  75.              'Hymn 6': 'The text of hymn 6', 'Hymn 7': 'The text of hymn 7', 'Hymn 8': 'The text of hymn 8',
  76.              'Hymn 9': 'The text of hymn 9', 'Hymn 10': 'The text of hymn 10', 'Hymn 11': 'The text of hymn 11',
  77.              'Hymn 12': 'The text of hymn 12', 'Hymn 13': 'The text of hymn 13', 'Hymn 14': 'The text of hymn 14',
  78.              'Hymn 15': 'The text of hymn 15', 'Hymn 16': 'The text of hymn 16'}
  79.  
  80.     def go_to_page(self, page):
  81.         app = App.get_running_app()
  82.         sm = app.root.ids.sm
  83.         sm.current = 'contents'
  84.         sm.get_screen('contents').ids.label.text = str(self.hymns[page])
  85.  
  86.  
  87. class TableOfContentsScreen(Screen):
  88.     def on_kv_post(self, base_widget):
  89.         grid = self.ids.grid
  90.         for i in range(1, 17):
  91.             grid.add_widget(PageButton(text=f'Hymn {i}'))
  92.  
  93. class search(Screen):
  94.     pass
  95.  
  96. class ContentScreen(Screen):
  97.     pass
  98.  
  99.  
  100. class HymnApp(App):
  101.     def build(self):
  102.         return Builder.load_string(kv)
  103.  
  104.  
  105. HymnApp().run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement