Advertisement
Guest User

Untitled

a guest
Apr 5th, 2020
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.63 KB | None | 0 0
  1. # luis carlos pallares ascanio
  2. # card in RecycleView
  3. from kivymd.app import MDApp
  4. from kivy.factory import Factory
  5. from kivy.lang import Builder
  6. from kivy.metrics import dp
  7. from kivy.core.window import Window
  8. from kivymd.uix.list import OneLineAvatarListItem
  9. from kivy.properties import ListProperty, StringProperty
  10. from kivy.uix.modalview import ModalView
  11.  
  12. from kivymd.uix.card import MDCard
  13. #from kivymd.toast import toast
  14.  
  15. Builder.load_string("""
  16. #:import MDRaisedButton kivymd.uix.button.MDRaisedButton
  17. #:import hex kivy.utils.get_color_from_hex
  18. #:import MDDropdownMenu kivymd.uix.menu.MDDropdownMenu
  19.  
  20. <MiEtiqueta@Label>
  21.    # color: 0, 0, 0, 1
  22.    # color: 1, 1, 1, 1
  23.    # color: hex("#4E5862")
  24.    size_hint: None, None
  25.    size: self.texture_size
  26.    pos_hint: {'center_y': .5}
  27.    multiline: True
  28.  
  29. <MiBotonIcono@MDIconButton>
  30.    theme_text_color: 'Custom'
  31.    text_color: hex("#afafaf")
  32.    # pos_hint: {"down": .1, "left": .1}
  33.    size_hint: 1, 1
  34.  
  35. <MiPantalla@Screen>
  36.    RecycleView:
  37.        id: reciclaje
  38.        key_viewclass: 'viewclass'
  39.        key_size: 'height'
  40.  
  41.        RecycleBoxLayout:
  42.            padding: dp(0)
  43.            spacing: dp(10)
  44.            default_size: None, dp(48)
  45.            default_size_hint: 1, None
  46.            size_hint_y: None
  47.            height: self.minimum_height
  48.            orientation: 'vertical'
  49.            canvas:
  50.                Color:
  51.                    rgb: hex("#17212d")
  52.                Rectangle:
  53.                    size: self.size
  54.                    pos: self.pos
  55.  
  56. <Tarjetas>
  57.    padding: dp(0)
  58.    spacing: dp(5)
  59.    elevation: 10
  60.    canvas:
  61.        Color:
  62.            rgb: hex("#1b2936")
  63.        Rectangle:
  64.            size: self.size
  65.            pos: self.pos
  66.  
  67.    BoxLayout:
  68.        orientation: 'vertical'
  69.        Contenido:
  70.  
  71.        Iconos:
  72.  
  73.  
  74. <Contenido@MDBoxLayout>:
  75.    orientation: 'vertical'
  76.    #adaptive_height: True
  77.    md_bg_color: hex("#1b2936")
  78.  
  79.    MDBoxLayout:
  80.        orientation: 'vertical'
  81.        size_hint: 1, .2
  82.        #adaptive_height: True
  83.        #md_bg_color: hex("#000000")
  84.  
  85.        MiEtiqueta:
  86.            text:
  87.                '''
  88.                'El aventurero espacial Peter Quill se convierte en presa
  89.                'él hace una alianza con un grupo de cuatro alienígenas.
  90.                '''.replace("'", '')
  91.        MiEtiqueta:
  92.            text: 'colombia'
  93.            color: hex("#F25050")
  94.  
  95.    Image:
  96.        size_hint: 1, .715
  97.        canvas.before:
  98.            Color:
  99.                rgb: hex("#a3a4a4")
  100.            Rectangle:
  101.                size: self.size
  102.                pos: self.pos
  103.        source: "go.jpg"
  104.  
  105.  
  106. <Iconos@MDBoxLayout>:
  107.    orientation: 'horizontal'
  108.    size_hint: 1, .1
  109.    #adaptive_height: True
  110.    #md_bg_color: hex("#000000")
  111.  
  112.    MiBotonIcono:
  113.        icon: 'arrow-up-bold-circle'
  114.        # size_hint: 1, .1
  115.        on_press:
  116.            self.text_color = hex("#ff8c60") if self.text_color == hex("#afafaf") else hex("#afafaf")
  117.    MiBotonIcono:
  118.        icon: 'arrow-down-bold-circle'
  119.        # size_hint: 1, .1
  120.        on_press:
  121.            self.text_color = hex("#7193ff") if self.text_color == hex("#afafaf") else hex("#afafaf")
  122.    MiBotonIcono:
  123.        icon: 'star'
  124.        on_press:
  125.            self.text_color = hex("#fec409") if self.text_color == hex("#afafaf") else hex("#afafaf")
  126.    MiBotonIcono:
  127.        icon: 'comment-text-outline'
  128.    MiBotonIcono:
  129.        icon: 'exit-to-app'
  130.    MiBotonIcono:
  131.        icon: 'dots-vertical'
  132.        on_release:
  133.            app.abrir()
  134.  
  135. <ElementosLista>
  136.    theme_text_color: 'Custom'
  137.    divider: None
  138.    color: hex("#4E5862")
  139.  
  140.    IconLeftWidget:
  141.        icon: root.icono
  142.        text_color: hex("#afafaf")
  143.  
  144. <VentanaEmergente>
  145.    size_hint: None, None
  146.    size: 327, 427
  147.  
  148.    # ELEMENTOS
  149.    ScrollView:
  150.        id: sc
  151.        pos_hint: {"top": 1}
  152.  
  153.        MDGridLayout:
  154.            id: box_item
  155.            cols: 1
  156.            size_hint_y: None
  157.            height: self.minimum_height
  158.            #adaptive_height: True
  159.            #md_bg_color: hex("#1b2936")
  160.            #md_bg_color: app.theme_cls.primary_color
  161.  
  162.  
  163. """)
  164.  
  165.  
  166. class Tarjetas(MDCard):
  167.     '''
  168.    def abrir(self):
  169.        popup = VentanaEmergente()
  170.        popup.open()
  171.    '''
  172.  
  173.  
  174. class ElementosLista(OneLineAvatarListItem):
  175.     icono = StringProperty()
  176.  
  177.  
  178. class VentanaEmergente(ModalView):
  179.     def __init__(self, **kwargs):
  180.         super().__init__(**kwargs)
  181.         for items in {
  182.             "home-circle-outline": "Inicio",
  183.             "update": "Buscar Actualizacion",
  184.             "settings-outline": "Ajustes",
  185.             "exit-to-app": "Salir",
  186.         }.items():
  187.             self.ids.box_item.add_widget(
  188.                 ElementosLista(
  189.                     text=items[1],
  190.                     icono=items[0],
  191.                 )
  192.             )
  193.  
  194.  
  195. class Test(MDApp):
  196.     menu_items = ListProperty()
  197.  
  198.     def __init__(self, **kwargs):
  199.         self.title = "Boost"
  200.         super().__init__(**kwargs)
  201.  
  202.     '''
  203.    def build(self):
  204.        return Factory.MiPantalla()
  205.    '''
  206.  
  207.     def build(self):
  208.         self.root = Factory.MiPantalla()
  209.  
  210.     def on_start(self):
  211.         for i in range(5000):  # 50 Tarjetas en reciclaje
  212.             self.root.ids.reciclaje.data.append(
  213.                 {
  214.                     "viewclass": "Tarjetas",
  215.                     "height": dp(450)  # tamaño tarjetas 64
  216.                 }
  217.             )
  218.  
  219.     def abrir(self):
  220.         popup = VentanaEmergente()
  221.         popup.open()
  222.  
  223.  
  224. if __name__ == '__main__':
  225.     #Window.size = (361, 641) #size of phone
  226.     Test().run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement