def __init__(self): super().__init__() labels = { 'width' : 70, 'fontcolor' : WHITE, 'border' : 2, 'fgcolor' : RED, 'bgcolor' : (0, 40, 0), 'font' : font14, } radiobuttons = [ {'text' : '1', 'args' : ['1']}, {'text' : '2', 'args' : ['2']}, {'text' : '3', 'args' : ['3']}, {'text' : '4', 'args' : ['4']}, ] buttonlist = [ {'fgcolor' : GREEN, 'shape' : CLIPPED_RECT, 'text' : 'Start', 'args' : ['Live']}, {'fgcolor' : RED, 'shape' : CLIPPED_RECT, 'text' : 'Stop', 'args' : ['Die']}, ] backbutton(390, 242) fwdbutton(0, 242, BackScreen) lstlbl = [] for n in range(4): lstlbl.append(Label((350, 40 * n), **labels)) self.led = LED((440, 0), border = 2) Checkbox((300, 0), callback = self.cbcb, args = [lstlbl[0], False]) Checkbox((300, 40), fillcolor = RED, callback = self.cbcb, args = [lstlbl[1], True]) # On/Off toggle x = 1 bs = ButtonList(self.callback) bs0 = None for t in buttonlist: # Buttons overlay each other at same location t['args'].append(lstlbl[2]) button = bs.add_button((x, 120), font = font14, fontcolor = BLACK, **t) if bs0 is None: bs0 = button # Radio buttons x = 1 rb = RadioButtons(BLUE, self.callback) # color of selected button for t in radiobuttons: t['args'].append(lstlbl[3]) button = rb.add_button((x, 180), font = font14, fontcolor = WHITE, fgcolor = (0, 0, 90), height = 40, width = 40, **t) x += 60
def __init__(self): super().__init__() # Common args for the labels labels = { 'width' : 70, 'fontcolor' : WHITE, 'border' : 2, 'fgcolor' : RED, 'bgcolor' : (0, 40, 0), } # Common arguments for all three sliders table = {'fontcolor' : WHITE, 'legends' : ('0', '5', '10'), 'cb_end' : self.slide_release, } self.led = LED((420, 0), border = 2) meter1 = Meter((320, 0), font=font10, legends=('0','5','10'), pointercolor = YELLOW, fgcolor = GREEN) meter2 = Meter((360, 0), font=font10, legends=('0','5','10'), pointercolor = YELLOW) btnquit = Button((390, 240), font = font14, callback = self.quit, fgcolor = RED, text = 'Quit', shape = RECTANGLE, width = 80, height = 30) # Create labels x = 230 lstlbl = [] for n in range(3): lstlbl.append(Label((x, 40 + 60 * n), font = font10, **labels)) # Sliders x = 10 self.slave1 = HorizSlider((x, 100), font = font10, fgcolor = GREEN, cbe_args = ('Slave1',), cb_move = self.slave_moved, cbm_args = (lstlbl[1],), **table) self.slave2 = HorizSlider((x, 160), font = font10, fgcolor = GREEN, cbe_args = ('Slave2',), cb_move = self.slave_moved, cbm_args = (lstlbl[2],), **table) master = HorizSlider((x, 40), font = font10, fgcolor = YELLOW, cbe_args = ('Master',), cb_move = self.master_moved, slidecolor=RED, border = 2, cbm_args = (lstlbl[0],), value=0.5, **table) # On/Off toggle: enable/disable bs = ButtonList(self.cb_en_dis) self.lst_en_dis = [self.slave1, btnquit] button = bs.add_button((280, 240), font = font14, fontcolor = BLACK, height = 30, width = 90, fgcolor = GREEN, shape = RECTANGLE, text = 'Disable', args = (True,)) button = bs.add_button((280, 240), font = font14, fontcolor = BLACK, height = 30, width = 90, fgcolor = RED, shape = RECTANGLE, text = 'Enable', args = (False,)) # Threads to test meters Screen.objsched.add_thread(self.testmeter(meter1)) Screen.objsched.add_thread(self.testmeter(meter2))
def __init__(self): super().__init__() Button((390, 240), font=font14, callback=self.quit, fgcolor=RED, text='Quit', shape=RECTANGLE, width=80, height=30) self.dial = Dial((120, 0), fgcolor=YELLOW, border=2, pointers=(0.9, 0.7)) k0 = Knob((0, 0), fgcolor=GREEN, bgcolor=(0, 0, 80), color=(168, 63, 63), border=2, cb_end=self.callback, cbe_args=['Knob1'], cb_move=self.knob_moved, cbm_args=(0, )) k1 = Knob((0, 120), fgcolor=WHITE, border=2, arc=pi * 1.5, cb_end=self.callback, cbe_args=['Knob2'], cb_move=self.knob_moved, cbm_args=(1, )) # Dropdown self.lbl_dd = Label((120, 120), font=font14, width=100, border=2, bgcolor=(0, 40, 0), fgcolor=RED) self.dropdown = Dropdown( (280, 0), font=font14, width=100, callback=self.cbdb, elements=('Dog', 'Cat', 'Rat', 'Goat', 'Snake', 'Pig')) Button((280, 70), font=font14, callback=self.set_dropdown, fgcolor=BLUE, text='Reset', shape=RECTANGLE, width=80, height=30) # Test of set by value Button((280, 120), font=font14, callback=self.set_bytext, args=('Snake', ), fgcolor=CYAN, fontcolor=BLACK, text='Snake', shape=RECTANGLE, width=80, height=30) # test set by text # Listbox self.listbox = Listbox( (370, 70), font=font14, width=105, bgcolor=GREY, fgcolor=YELLOW, select_color=BLUE, elements=('aardvark', 'zebra', 'armadillo', 'warthog'), callback=self.cblb) # On/Off toggle grey style self.lbl_style = Label((170, 210), font=font10, value='Current style: grey') bstyle = ButtonList(self.cb_style) bstyle.add_button((170, 240), font=font14, fontcolor=WHITE, height=30, width=90, fgcolor=RED, shape=RECTANGLE, text='Dim', args=(False, )) bstyle.add_button((170, 240), font=font14, fontcolor=WHITE, height=30, width=90, fgcolor=GREEN, shape=RECTANGLE, text='Grey', args=(True, )) # On/Off toggle enable/disable bs = ButtonList(self.cb_en_dis) self.lst_en_dis = (bstyle, k0, k1, self.dropdown, self.listbox) bs.add_button((280, 240), font=font14, fontcolor=BLACK, height=30, width=90, fgcolor=GREEN, shape=RECTANGLE, text='Disable', args=(True, )) bs.add_button((280, 240), font=font14, fontcolor=BLACK, height=30, width=90, fgcolor=RED, shape=RECTANGLE, text='Enable', args=(False, ))
def __init__(self): super().__init__() # Common args for the labels labels = { 'width': 70, 'fontcolor': WHITE, 'border': 2, 'fgcolor': RED, 'bgcolor': (0, 40, 0), } # Common args for all three sliders table = { 'fontcolor': WHITE, 'legends': ('0', '5', '10'), 'cb_end': self.callback, } btnquit = Button((390, 240), font=font14, callback=self.quit, fgcolor=RED, text='Quit', shape=RECTANGLE, width=80, height=30) self.dial1 = Dial((350, 10), fgcolor=YELLOW, border=2, pointers=(0.9, 0.7)) self.dial2 = Dial((350, 120), fgcolor=YELLOW, border=2, pointers=(0.9, 0.7)) self.lstlbl = [] for n in range(3): self.lstlbl.append(Label((80 * n, 240), font=font10, **labels)) y = 5 self.slave1 = Slider((80, y), font=font10, fgcolor=GREEN, cbe_args=('Slave1', ), cb_move=self.slave_moved, cbm_args=(1, ), **table) self.slave2 = Slider((160, y), font=font10, fgcolor=GREEN, cbe_args=('Slave2', ), cb_move=self.slave_moved, cbm_args=(2, ), **table) master = Slider((0, y), font=font10, fgcolor=YELLOW, cbe_args=('Master', ), cb_move=self.master_moved, value=0.5, border=2, **table) Screen.objsched.add_thread(self.thread1()) Screen.objsched.add_thread(self.thread2()) # On/Off toggle: enable/disable quit button and one slider bs = ButtonList(self.cb_en_dis) lst_en_dis = [self.slave1, btnquit] button = bs.add_button((280, 240), font=font14, fontcolor=BLACK, height=30, width=90, fgcolor=GREEN, shape=RECTANGLE, text='Disable', args=[True, lst_en_dis]) button = bs.add_button((280, 240), font=font14, fontcolor=BLACK, height=30, width=90, fgcolor=RED, shape=RECTANGLE, text='Enable', args=[False, lst_en_dis])
def __init__(self): super().__init__() # These tables contain args that differ between members of a set of related buttons table = [ {'fgcolor' : GREEN, 'text' : 'Yes', 'args' : ('Oui', 2), 'fontcolor' : (0, 0, 0)}, {'fgcolor' : RED, 'text' : 'No', 'args' : ('Non', 2)}, {'fgcolor' : BLUE, 'text' : '???', 'args' : ('Que?', 2), 'fill': False}, {'fgcolor' : GREY, 'text' : 'Rats', 'args' : ('Rats', 2), 'shape' : CLIPPED_RECT,}, ] # Highlight buttons: only tabulate data that varies table_highlight = [ {'text' : 'P', 'args' : ('p', 2)}, {'text' : 'Q', 'args' : ('q', 2)}, {'text' : 'R', 'args' : ('r', 2)}, {'text' : 'S', 'args' : ('s', 2)}, ] # A Buttonset with two entries table_buttonset = [ {'fgcolor' : GREEN, 'shape' : CLIPPED_RECT, 'text' : 'Start', 'args' : ('Live', 2)}, {'fgcolor' : RED, 'shape' : CLIPPED_RECT, 'text' : 'Stop', 'args' : ('Die', 2)}, ] table_radiobuttons = [ {'text' : '1', 'args' : ('1', 3)}, {'text' : '2', 'args' : ('2', 3)}, {'text' : '3', 'args' : ('3', 3)}, {'text' : '4', 'args' : ('4', 3)}, ] labels = { 'width' : 70, 'fontcolor' : WHITE, 'border' : 2, 'fgcolor' : RED, 'bgcolor' : (0, 40, 0), 'font' : font14, } # Uncomment this line to see 'skeleton' style greying-out: # Screen.tft.grey_color() # Labels self.lstlbl = [] for n in range(5): self.lstlbl.append(Label((390, 40 * n), **labels)) # Button assortment x = 0 for t in table: Button((x, 0), font = font14, callback = self.callback, **t) x += 70 # Highlighting buttons x = 0 for t in table_highlight: Button((x, 60), fgcolor = GREY, fontcolor = BLACK, litcolor = WHITE, font = font14, callback = self.callback, **t) x += 70 # Start/Stop toggle self.bs = ButtonList(self.callback) self.bs0 = None for t in table_buttonset: # Buttons overlay each other at same location button = self.bs.add_button((0, 240), font = font14, fontcolor = BLACK, height = 30, **t) if self.bs0 is None: # Save for reset button callback self.bs0 = button # Radio buttons x = 0 self.rb = RadioButtons(BLUE, self.callback) # color of selected button self.rb0 = None for t in table_radiobuttons: button = self.rb.add_button((x, 140), font = font14, fontcolor = WHITE, fgcolor = (0, 0, 90), height = 40, width = 40, **t) if self.rb0 is None: # Save for reset button callback self.rb0 = button x += 60 # Checkbox self.cb1 = Checkbox((340, 0), callback = self.cbcb, args = (0,)) self.cb2 = Checkbox((340, 40), fillcolor = RED, callback = self.cbcb, args = (1,)) # Reset button self.lbl_reset = Label((200, 220), font = font10, value = 'Reset also responds to long press') self.btn_reset = Button((300, 240), font = font14, height = 30, width = 80, fgcolor = BLUE, shape = RECTANGLE, text = 'Reset', fill = True, callback = self.cbreset, args = (4,), onrelease = False, lp_callback = self.callback, lp_args = ('long', 4)) # Quit self.btn_quit = Button((390, 240), font = font14, height = 30, width = 80, fgcolor = RED, shape = RECTANGLE, text = 'Quit', callback = self.quit) # Enable/Disable toggle self.bs_en = ButtonList(self.cb_en_dis) self.tup_en_dis = (self.cb1, self.cb2, self.rb, self.bs) # Items affected by enable/disable button self.bs_en.add_button((200, 240), font = font14, fontcolor = BLACK, height = 30, width = 90, fgcolor = GREEN, shape = RECTANGLE, text = 'Disable', args = (True,)) self.bs_en.add_button((200, 240), font = font14, fontcolor = BLACK, height = 30, width = 90, fgcolor = RED, shape = RECTANGLE, text = 'Enable', args = (False,))