Injectable widgets in kv lang?
Is it possible somehow to inject content into inherited widgets? Here comes an example in pseudo code of what I would like to do:
#: abstract BaseScreen@Screen:` Label: text: 'Top label'
#: inject_from("Content1")
Label: text: 'bottom label'
HomeScreen@BaseScreen: Content1: Label: text: 'This label will be place between first and second label!" `
Is this functionality possible today (preferably through kv language only)?
Here it is
#:import Content1 path.to.content.Content1
<BaseScreen@Screen>:
Label:
text: 'Top Label'
Label:
text: 'Bottom Label'
<HomeScreen@BaseScreen>:
Content1:
Label:
text: 'This label will be place between first and second label!'
This will render, in this order
Top Label
Bottom Label
actual content of Content1
This label will be place between first and second label!
To acheive
Top Label
actual content of Content1
This label will be place between first and second label!
Bottom Label
You might need to do some pythonic stuff
Consider visiting https://kivy.org/doc/stable/guide/lang.html to more learn about kv lang
I think it is not possible solely on the kv language side. But after you define widgets in the kv language in an ordered layout such as boxlayout, then you may remove the last label through ids of the screen and then add your content+label or necessary changes from the python side.