kivy/kivy — Issue #408: Kivy Lang Enhancement
Author: rubik
Created: 2012-02-24 15:00:58+00:00
State: open

I have a .kv file where I design a grid layout with a lot of buttons (a limited keyword). Although the buttons text is different, they are pretty much the same (size, font_size, &c.). It would be very useful to allow the creation of *abstract* widgets in the kv file.
A little example:

# current method
Button:
text: '+'
size: 110, 110
font_size: 35
size_hint: None, None
on_release: root.type_in(self)

Button:
text: '-'
size: 110, 110
font_size: 35
size_hint: None, None
on_release: root.type_in(self)

Button:
text: '*'
size: 110, 110
font_size: 35
size_hint: None, None
on_release: root.type_in(self)

Button:
text: '/'
size: 110, 110
font_size: 35
size_hint: None, None
on_release: root.type_in(self)

and with this new feature:

Button:
id: my_abstract_button
abstract: True
size: 110, 110
font_size: 35
size_hint: None, None
on_release: root.type_in(self)

Button:
bases: my_abstract_button
text: '+'

Button:
bases: my_abstract_button
text: '-'

Button:
bases: my_abstract_button
text: '*'

Button:
bases: my_abstract_button
text: '/'

Clearly, the abstract widget does not need to be a widget in the code, it could be a dictionary holding attributes...

Thank you for your work,
rubik