def __init__(self): super().__init__() labels = { 'width' : 50, 'fontcolor' : WHITE, 'border' : 2, 'fgcolor' : RED, 'bgcolor' : DARKGREEN, 'font' : font10, } quitbutton() self.dial = Dial((109, 0), fgcolor = YELLOW, border = 2, pointers = (0.9, 0.7)) self.lbl_result = Label((109, 80), **labels) self.master = Slider((0, 5), font = font6, fgcolor = YELLOW, fontcolor = WHITE, legends = ('0', '5', '10'), cb_end = self.callback, cbe_args = ('Master',), cb_move = self.master_moved, value=0.5, border = 2) self.slave = Slider((60, 5), fgcolor = GREEN, cbe_args = ('Slave',), cb_move = self.slave_moved, border = 2) self.reg_task(self.coro()) # On/Off toggle: enable/disable quit button and one slider bs = ButtonList(self.cb_en_dis) lst_en_dis = [self.slave, self.master] button = bs.add_button((109, 53), font = font10, fontcolor = BLACK, fgcolor = GREEN, text = 'Dis', args = [True, lst_en_dis]) button = bs.add_button((109, 53), font = font10, fontcolor = BLACK, fgcolor = RED, text = 'En', args = [False, lst_en_dis])
def __init__(self): super().__init__() table_highlight = [ { 'text': 'Highlight', 'args': (HighlightScreen, ) }, { 'text': 'Radio', 'args': (RadioScreen, ) }, { 'text': 'Assorted', 'args': (AssortedScreen, ) }, { 'text': 'Checkbox', 'args': (CheckboxScreen, ) }, ] quitbutton() self.lst_en_dis = [] # List of objects controlled by Enable/Disable def rbcb(button, screen): # RadioButton callback Screen.change(screen) rb = RadioButtons(BLUE, rbcb) # color of selected button self.lst_en_dis.append(rb) y = 0 for t in table_highlight: rb.add_button((0, y), font=font10, fgcolor=DARKBLUE, onrelease=False, width=80, fontcolor=WHITE, **t) y += 25 # Enable/Disable toggle self.bs_en = ButtonList(self.cb_en_dis) self.bs_en.add_button((0, 107), font=font10, fontcolor=BLACK, width=60, fgcolor=GREEN, text='Disable', args=(True, )) self.bs_en.add_button((0, 107), font=font10, fontcolor=BLACK, width=60, fgcolor=RED, text='Enable', args=(False, ))
def __init__(self): super().__init__() quitbutton() # Dropdown self.lbl_dd = Label((0, 80), font=font10, width=60, border=2, bgcolor=DARKGREEN, fgcolor=RED) self.dropdown = Dropdown((0, 0), font=font10, width=65, callback=self.cbdb, elements=('Dog', 'Cat', 'Rat', 'Goat', 'Pig')) # Listbox self.listbox = Listbox( (80, 0), font=font10, width=79, bgcolor=GREY, fgcolor=YELLOW, select_color=BLUE, elements=('aardvark', 'zebra', 'armadillo', 'warthog'), callback=self.cblb) self.btnrep = Button((0, 40), height=20, font=font10, callback=self.cbrep, fgcolor=RED, text='Report', shape=RECTANGLE, width=60) # Enable/Disable toggle self.bs_en = ButtonList(self.cb_en_dis) self.bs_en.add_button((0, 107), font=font10, fontcolor=BLACK, height=20, width=60, fgcolor=GREEN, shape=RECTANGLE, text='Disable', args=(True, )) self.bs_en.add_button((0, 107), font=font10, fontcolor=BLACK, height=20, width=60, fgcolor=RED, shape=RECTANGLE, text='Enable', args=(False, ))
def __init__(self): super().__init__() # These tables contain args that differ between members of a set of related buttons table = [ { 'fgcolor': GREEN, 'text': 'Y', 'args': ('Oui', ), 'fontcolor': (0, 0, 0), 'height': 30, 'shape': CIRCLE }, { 'fgcolor': RED, 'text': 'N', 'args': ('Non', ), 'height': 30, 'shape': CIRCLE }, { 'fgcolor': BLUE, 'bgcolor': BLACK, 'text': '?', 'args': ('Que?', ), 'fill': False, 'height': 30, 'shape': CIRCLE }, { 'fgcolor': GREY, 'text': '$', 'args': ('Rats', ), 'height': 30, 'width': 30, 'shape': CLIPPED_RECT }, ] # A Buttonset with two entries table_buttonset = [ { 'fgcolor': YELLOW, 'text': 'Start', 'args': ('Live', ) }, { 'fgcolor': RED, 'text': 'Stop', 'args': ('Die', ) }, ] # Uncomment this line to see 'skeleton' style greying-out: # Screen.tft.grey_color() self.lbl_result = Label((109, 53), **labels) backbutton() # Button assortment self.buttons = [] x = 0 for t in table: b = Button((x, 0), font=font10, callback=self.callback, **t) self.buttons.append(b) x += 43 # Start/Stop toggle self.bs = ButtonList(self.callback) self.buttons.append(self.bs) self.bs0 = None for t in table_buttonset: # Buttons overlay each other at same location button = self.bs.add_button((0, 53), shape=CLIPPED_RECT, font=font10, width=60, fontcolor=BLACK, **t) if self.bs0 is None: # Save for reset button callback self.bs0 = button # Reset button r = self.btn_reset = Button((109, 80), font=font10, fgcolor=BLUE, text='Reset', fill=True, callback=self.cbreset, onrelease=False, lp_callback=self.callback, lp_args=('long', )) self.buttons.append(r) # Enable/Disable toggle self.bs_en = ButtonList(self.cb_en_dis) self.bs_en.add_button((0, 107), font=font10, fontcolor=BLACK, width=60, fgcolor=GREEN, text='Disable', args=(True, )) self.bs_en.add_button((0, 107), font=font10, fontcolor=BLACK, width=60, fgcolor=RED, text='Enable', args=(False, ))
class BaseScreen(Screen): def __init__(self): super().__init__() quitbutton() # Dropdown self.lbl_dd = Label((0, 80), font=font10, width=60, border=2, bgcolor=DARKGREEN, fgcolor=RED) self.dropdown = Dropdown((0, 0), font=font10, width=65, callback=self.cbdb, elements=('Dog', 'Cat', 'Rat', 'Goat', 'Pig')) # Listbox self.listbox = Listbox( (80, 0), font=font10, width=79, bgcolor=GREY, fgcolor=YELLOW, select_color=BLUE, elements=('aardvark', 'zebra', 'armadillo', 'warthog'), callback=self.cblb) self.btnrep = Button((0, 40), height=20, font=font10, callback=self.cbrep, fgcolor=RED, text='Report', shape=RECTANGLE, width=60) # Enable/Disable toggle self.bs_en = ButtonList(self.cb_en_dis) self.bs_en.add_button((0, 107), font=font10, fontcolor=BLACK, height=20, width=60, fgcolor=GREEN, shape=RECTANGLE, text='Disable', args=(True, )) self.bs_en.add_button((0, 107), font=font10, fontcolor=BLACK, height=20, width=60, fgcolor=RED, shape=RECTANGLE, text='Enable', args=(False, )) def cb_en_dis(self, button, disable): self.listbox.greyed_out(disable) self.dropdown.greyed_out(disable) self.btnrep.greyed_out(disable) def cbdb(self, dropdown): self.lbl_dd.value(dropdown.textvalue()) print('dropdown callback:', dropdown.textvalue(), dropdown.value()) def cblb(self, listbox): print('listbox callback:', listbox.textvalue(), listbox.value()) def cbrep(self, _): print('Report:') print('listbox', self.listbox.textvalue(), self.listbox.value()) print('dropdown', self.dropdown.textvalue(), self.dropdown.value())