Guest User

Untitled

a guest
Feb 17th, 2020
71
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from kivy.app import App
  2. from kivy.lang import Builder
  3. from kivy.uix.boxlayout import BoxLayout
  4. from kivy.uix.button import Button
  5. from kivy.uix.label import Label
  6.  
  7. Builder.load_string('''
  8. <CyberLabel>:
  9. text_size: self.size
  10. halign: 'center'
  11. valign: 'middle'
  12. pos_hint: {'center_y': 0.5}
  13. <CyberBox>:
  14. orientation: 'horizontal'
  15. padding: 50
  16. size_hint_y: None
  17. height: 70
  18. canvas.before:
  19. Color:
  20. rgba: 1, 1, 1, 1
  21. Line:
  22. width: 1
  23. rectangle: self.x, self.y, self.width, self.height
  24. ''')
  25.  
  26.  
  27. class CyberBox(BoxLayout):
  28. pass
  29.  
  30.  
  31. class CyberLabel(Label):
  32. pass
  33.  
  34.  
  35. class MainBox(BoxLayout):
  36. def __init__(self, **kwargs):
  37. self.orientation = 'vertical'
  38. super().__init__(**kwargs)
  39. box = CyberBox()
  40. box.add_widget(CyberLabel(text='a'))
  41. box.add_widget(CyberLabel(text='b'))
  42. button = Button(text='X', size_hint_x=None, width=100, pos_hint={'center_y': 0.5})
  43. button.bind(on_press=lambda _: print(_))
  44. box.add_widget(button)
  45. self.add_widget(box)
  46.  
  47.  
  48. class MainApp(App):
  49. def build(self):
  50. return MainBox()
  51.  
  52.  
  53. main = MainApp()
  54. main.run()
RAW Paste Data