Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from kivy.app import App
- from kivy.lang import Builder
- from kivy.uix.boxlayout import BoxLayout
- from kivy.uix.button import Button
- from kivy.uix.label import Label
- Builder.load_string('''
- <CyberLabel>:
- text_size: self.size
- halign: 'center'
- valign: 'middle'
- pos_hint: {'center_y': 0.5}
- <CyberBox>:
- orientation: 'horizontal'
- padding: 50
- size_hint_y: None
- height: 70
- canvas.before:
- Color:
- rgba: 1, 1, 1, 1
- Line:
- width: 1
- rectangle: self.x, self.y, self.width, self.height
- ''')
- class CyberBox(BoxLayout):
- pass
- class CyberLabel(Label):
- pass
- class MainBox(BoxLayout):
- def __init__(self, **kwargs):
- self.orientation = 'vertical'
- super().__init__(**kwargs)
- box = CyberBox()
- box.add_widget(CyberLabel(text='a'))
- box.add_widget(CyberLabel(text='b'))
- button = Button(text='X', size_hint_x=None, width=100, pos_hint={'center_y': 0.5})
- button.bind(on_press=lambda _: print(_))
- box.add_widget(button)
- self.add_widget(box)
- class MainApp(App):
- def build(self):
- return MainBox()
- main = MainApp()
- main.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement