Skip to content

Instantly share code, notes, and snippets.

@inclement
Created June 14, 2013 00:19
Show Gist options
  • Save inclement/5778531 to your computer and use it in GitHub Desktop.
Save inclement/5778531 to your computer and use it in GitHub Desktop.
class NumberChooser(BoxLayout):
number = NumericProperty(0)
number_max = NumericProperty(9)
number_min = NumericProperty(0)
def increment(self):
if self.number < self.number_max:
self.number += 1
def decrement(self):
if self.number > self.number_min:
self.number -= 1
NumberChooser>:
orientation: 'horizontal'
Button:
size_hint_x: None
width: self.parent.height
on_press: root.decrement()
canvas:
Line:
points: [self.x + 0.15*self.width,self.y+0.5*self.height,self.x+0.85*self.width,self.y+0.5*self.height]
width: 2
cap: 'square'
Label:
font_size: (0.9*self.height,'px')
text: str(root.number)
Button:
size_hint_x: None
width: self.parent.height
on_press: root.increment()
canvas:
Line:
points: [self.x + 0.15*self.width,self.y+0.5*self.height,self.x+0.85*self.width,self.y+0.5*self.height]
width: 2
cap: 'square'
Line:
points: [self.x + 0.5*self.width,self.y+0.15*self.height,self.x+0.5*self.width,self.y+0.85*self.height]
width: 2
cap: 'square'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment