1. Dusty Phillips
  2. kivy-catalog


Dusty Phillips  committed 3ce3f3e

Add a float layout demo

  • Participants
  • Parent commits b414e68
  • Branches master

Comments (0)

Files changed (2)

File kivycatalog.kv

View file
                 id: layout_tab
                     on_collapse: root.show_kv(*args)
+                    title: "FloatLayout"
+                    kv_container: floatlayoutcontainer
+                    FloatLayoutContainer:
+                        id: floatlayoutcontainer
+                AccordionItem:
+                    on_collapse: root.show_kv(*args)
                     title: "BoxLayout"
-                    # I suppose it's possible to introspect this from the class name
                     kv_container: boxlayoutcontainer
                         id: boxlayoutcontainer

File main.py

View file
 from kivy.properties import ObjectProperty
 from kivy.uix.boxlayout import BoxLayout
+from kivy.uix.floatlayout import FloatLayout
 from kivy.uix.popup import Popup
 from kivy.uix.label import Label
+# TODO: Documentation
-class BoxLayoutContainer(BoxLayout):
-    kv_file = "boxlayoutcontainer.kv"
+class Container(object):
     def __init__(self, **kwargs):
-        super(BoxLayoutContainer, self).__init__(**kwargs)
+        super(Container, self).__init__(**kwargs)
         parser = Parser(content=file(self.kv_file).read())
         Builder._apply_rule(self, parser.root, parser.root)
+class BoxLayoutContainer(Container, BoxLayout):
+    kv_file = "boxlayoutcontainer.kv"
+class FloatLayoutContainer(Container, FloatLayout):
+    kv_file = "floatlayoutcontainer.kv"
 class Catalog(BoxLayout):
     language_box = ObjectProperty()
     def build(self):
         return Catalog()
-for cls in (BoxLayoutContainer,):
+for cls in (BoxLayoutContainer, FloatLayoutContainer):
     Factory.register(cls.__name__, cls)
 if __name__ == "__main__":