I'm trying to create a template for a layout which looks like the following:
|----------|
| |
| IMAGE | <--- Just an image (square)
| |
|----------|
|[btn][btn]| <--- GridLayout cols=2 of buttons
|[btn][btn]|
|[btn][btn]|
|[btn][btn]|
|[btn][btn]|
|[btn][btn]|
|----------|
the first part is easy (but I could be wrong, as I'm very new at kivy)
#:kivy 1.6
[SideBar@BoxLayout]:
orientation: 'vertical'
Image:
source: ctx.image
size_hint: (1, None)
height: root.width
GridLayout:
cols: 2
# What do I do here to make it easy to load a list of buttons?
I hope the inline comments make the example clear enough. In this case we are just passing the ref of the content to the function that adds widgets to the content.
There are situations where you might want to have access to the Widget as a attribute of your own class. In that case you can Use the following method.
The method above basically adds a ObjectProperty of the same name as the id, passes the reference of the widget referenced to by the id to it. So you, now have a attribute with the same name as the id in your python class for easy access. Using the above mentioned method your code would look something like this.
Give a try to python-micro-template(https://github.com/diyism/python-micro-template), you could load the remote dynamic template file: