Reputation: 1095
How can I do something like this with Kivy?
Upvotes: 5
Views: 5860
Reputation: 16031
Use the button's background_normal, background_down, and border to achieve this. Lets name the two pictures that you provided as normal.png and down.png. Please refer to the example below for details.
Button:
background_normal: 'normal.png'
background_down: 'down.png'
border: 30,30,30,30
import kivy
kivy.require('1.10.0')
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
Builder.load_string("""
<RoundedButtons>:
orientation: 'vertical'
Button:
text: '[color=3333ff][b]Rounded Button 1[/b][/color]'
markup: True
background_normal: 'normal.png'
background_down: 'down.png'
border: 30,30,30,30
Button:
text: '[color=ff3333][b]Rounded Button 2[/b][/color]'
markup: True
background_normal: 'normal.png'
background_down: 'down.png'
border: 30,30,30,30
""")
class RoundedButtons(BoxLayout):
pass
class TestApp(App):
def build(self):
return RoundedButtons()
if __name__ == "__main__":
TestApp().run()
Upvotes: 6