spacing=self._canvas.spacing[0]
)
- def export_to_kv(self, widget, indent=''):
+ def export_to_kv(self):
kv = """StackLayout:
orientation: '{orientation}'
padding: {padding}
spacing: {spacing}
-""".format(orientation=self.orientation, padding=self.padding, spacing=self.spacing)
+""".format(orientation=self._canvas.orientation, padding=self._canvas.padding, spacing=self._canvas.spacing)
indent = ' '
- stack = [self]
+ stack = [self._canvas]
widgets = self.walk(restrict=True)
next(widgets) # the first widget is the FormCanvas
+ next(widgets) # and the second is the inner StackLayout
for widget in widgets:
if not isinstance(widget, Grabbable):
# Look for the widget position inside the tree
stack.append(widget)
# Widget attributes
- kv += """{indent}height: 40
-{indent}size_hint: (1., None)
-{indent}text: '{text}'
-""".format(indent=indent*len(stack), text=widget.text)
+ for attr in ('height', 'size_hint', 'text'):
+ if hasattr(widget, attr):
+ kv += "{indent}{attr}: {value}\n".format(
+ indent=indent*len(stack),
+ attr=attr,
+ value=getattr(widget, attr)
+ )
return kv