FoxboyPrower

KivyStaticWorking

Jul 15th, 2019
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.08 KB | None | 0 0
  1. from kivy.app import App
  2. from kivy.lang import Builder
  3. from kivy.uix.widget import Widget
  4. from kivy.uix.label import Label
  5. from kivy.uix.boxlayout import BoxLayout
  6. from kivy.properties import StringProperty
  7. from kivy.uix.textinput import TextInput
  8.  
  9. Builder.load_string('''
  10. <StretchingLabel>:
  11.    size_hint_y: None
  12.    text_size: self.width, None
  13.    height: self.texture_size[1]
  14.    group: 'test'
  15.    canvas.before:
  16.        Color:
  17.            rgba: .7, .7, .7, 1
  18.        Rectangle:
  19.            pos: self.pos
  20.            size: self.size
  21.  
  22. <MyLabelFrame>:
  23.    id: xLabel
  24.    StretchingLabel:
  25.        width: xLabel.width
  26.         pos: xLabel.pos
  27.        text: xLabel.c_description
  28.  
  29. <ContainerBox>:
  30.     orientation: 'horizontal'
  31.    Button:
  32.        text: 'h1'
  33.        group: 'test'
  34.    BoxLayout:
  35.         orientation: 'vertical'
  36.         size: root.size
  37.         pos: root.pos
  38.         Label:
  39.             text: 'Description'
  40.             size_hint_y: None
  41.             height: 30
  42.             bold: True
  43.        MyLabelFrame:
  44.        Label:
  45. ''')
  46.  
  47. class MyLabelFrame(Widget):
  48.     c_description = StringProperty(
  49.         'Lorem ipsum dolor sit amet, consectetur adipiscing elit. \n\nProin vitae turpis ornare urna elementum pharetra non et tortor. Curabitur semper mattis viverra. \nPellentesque et lobortis purus, eu ultricies est. Nulla varius ac dolor quis mattis. Pellentesque vel accumsan tellus. Donec a nunc urna. Nulla convallis dignissim leo, tempor sagittis orci sollicitudin aliquet. Duis efficitur ex vel auctor ultricies. Etiam feugiat hendrerit mauris suscipit gravida. Quisque lobortis vitae ligula eget tristique. Nullam a nulla id enim finibus elementum eu sit amet elit.')
  50.  
  51.     def __init__(self, **kwargs):
  52.         super(MyLabelFrame, self).__init__(**kwargs)
  53.  
  54. class StretchingLabel(Label):
  55.     def __init__(self, **kwargs):
  56.         super(StretchingLabel, self).__init__(**kwargs)
  57.  
  58. class ContainerBox(BoxLayout):
  59.     def __init__(self, **kwargs):
  60.         super(ContainerBox, self).__init__(**kwargs)
  61.  
  62.  
  63. class Nested2App(App):
  64.     def build(self):
  65.         return ContainerBox()
  66.  
  67.  
  68. if __name__ == '__main__':
  69.     Nested2App().run()
Advertisement
Add Comment
Please, Sign In to add comment