Skip to content

Instantly share code, notes, and snippets.

@roberto-arista
Created February 19, 2019 21:53
Show Gist options
  • Save roberto-arista/b00f1cacb10389d10a6d263d88ffe544 to your computer and use it in GitHub Desktop.
Save roberto-arista/b00f1cacb10389d10a6d263d88ffe544 to your computer and use it in GitHub Desktop.
from vanilla import Window, RadioGroup, SquareButton
class ExampleCtrl(object):
ledsAmount = 6
index = 0
def __init__(self):
self.w = Window((150, 150), '% modulo')
self.w.someLeds = RadioGroup((20, 20, -20, -20),
[""]*self.ledsAmount,
callback=self.radioGroupCallback)
self.w.up = SquareButton((-60, 20, 40, 40), "↑",
callback=self.upCallback)
self.w.dw = SquareButton((-60, -60, 40, 40), "↓",
callback=self.dwCallback)
self.w.open()
def radioGroupCallback(self, sender):
print(sender.get())
def upCallback(self, sender):
self.index -= 1
self.w.someLeds.set(self.index % self.ledsAmount)
def dwCallback(self, sender):
self.index += 1
self.w.someLeds.set(self.index % self.ledsAmount)
ec = ExampleCtrl()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment