Following code from here I've created a simple button with rounded corners like so:
<RoundedButton@Button>:
background_color: 0,0,1,0
canvas.before:
Color:
rgba: (.216,.118,.329,1) if self.state=='normal' else (0,.7,.7,1)
RoundedRectangle:
pos: self.pos
size: self.size
radius: [10,]
RelativeLayout:
pos: self.parent.pos
size: self.parent.size
Label:
text: 'Button Text'
font_size: 20
pos_hint: {'center_x': 0.5,'center_y':0.5}
id: _labeltext
When I use this button in my kv code, I'd like a simple way to change the text of the button, which I'd like to do using the id value '_labeltext'. This seems like it should be simple but I've not been able to find how to change this in the KV code rather than in python (as a response to an action). I'd just like to reuse my button design multiple times with different text. For example (I know this doesn't work):
RoundedButton:
self.ids._labeltext.text: 'New Button Text'
Thanks
P.S. can't get indentation correct in the editor, apologies
kvis incorrect. Please adjust your postedkvto reflect the actual indentation used. Is theRelativeLayoutpart of theRoundedButton? - John Anderson