Skip to content

Instantly share code, notes, and snippets.

@Bakterija
Created June 11, 2017 18:58
Show Gist options
  • Save Bakterija/511f971ba2c3dfad63d45d8ac6d009e8 to your computer and use it in GitHub Desktop.
Save Bakterija/511f971ba2c3dfad63d45d8ac6d009e8 to your computer and use it in GitHub Desktop.
Kivy canvas colorable button with hover behavior
from kivy.properties import StringProperty, ListProperty
from kivy_soil.hover_behavior import HoverBehavior
from kivy.uix.behaviors import ButtonBehavior
from global_vars import theme_manager
from kivy.uix.widget import Widget
from kivy.lang import Builder
class HoverCanvasButton(HoverBehavior, ButtonBehavior, Widget):
source = StringProperty()
color = ListProperty([0.8, 0.8, 0.8, 1])
Builder.load_string('''
<HoverCanvasButton>:
canvas:
Color:
rgba: self.color
Rectangle:
source: self.source
size: self.size
pos: self.pos
''')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment