rickyc81

KivyMD

Sep 22nd, 2020
930
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from kivy.lang import Builder
  2.  
  3. from kivymd.app import MDApp
  4. from kivymd.uix.taptargetview import MDTapTargetView
  5.  
  6. KV = '''
  7. Screen:
  8.    id: screen
  9.  
  10.    MDFloatingActionButton:
  11.        id: button
  12.        icon: "plus"
  13.        pos: 10, 10
  14.        on_release: app.tap_target_start()
  15.        on_press: app.printIds()
  16.    
  17.    MDCard:
  18.        id: card
  19.        size_hint: None, None
  20.        size: "280dp", "180dp"
  21.        pos_hint: {"center_x": .5, "center_y": .5}
  22.  
  23.        MDLabel:
  24.            id: label
  25.            text: "MDLabel"
  26.            halign: "left"
  27.        
  28.  
  29.        MDIconButton:
  30.            id: button2
  31.            icon: "android"
  32.            theme_text_color: "Custom"
  33.            text_color: app.theme_cls.primary_color
  34.            on_press: app.printIds()
  35. '''
  36.  
  37.  
  38. class TapTargetViewDemo(MDApp):
  39.     def build(self):
  40.         screen = Builder.load_string(KV)
  41.         self.tap_target_view = MDTapTargetView(
  42.             widget=screen.ids.button,
  43.             title_text="This is an add button",
  44.             description_text="This is a description of the button",
  45.             widget_position="left_bottom",
  46.         )
  47.  
  48.         return screen
  49.  
  50.     def tap_target_start(self):
  51.         if self.tap_target_view.state == "close":
  52.             self.tap_target_view.start()
  53.         else:
  54.             self.tap_target_view.stop()
  55.  
  56.     def printIds(self):
  57.         self.root.ids.label.text = "e che cazzo"
  58.  
  59.  
  60. TapTargetViewDemo().run()
RAW Paste Data