Skip to content

Instantly share code, notes, and snippets.

@mike-perdide
Created November 22, 2012 18:03
Show Gist options
  • Select an option

  • Save mike-perdide/4132401 to your computer and use it in GitHub Desktop.

Select an option

Save mike-perdide/4132401 to your computer and use it in GitHub Desktop.
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.gridlayout import GridLayout
from kivy.uix.label import Label
from kivy.properties import BooleanProperty
Builder.load_string("""
<CustomLabel>
color: 1, .4, .4, 1
canvas.before:
Color:
rgba: 1, 0, 0, 1 if self.odd else 1, 0, 1, 1
Rectangle:
pos: self.pos
size: self.size
<TestWidget>
cols: 6
""")
class CustomLabel(Label):
odd = BooleanProperty(None)
class TestWidget(GridLayout):
def __init__(self):
GridLayout.__init__(self)
odd = True
for x in range(12):
widget = CustomLabel(text="item %d" % x, odd=odd)
self.add_widget(widget)
odd = not odd
class TestApp(App):
def build(self):
widget = TestWidget()
return widget
if __name__ == "__main__":
TestApp().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment