def __init__(self): super().__init__() Label((0, 0), font=font14, value='Dialog box demonstration.') Label((0, 100), font=font10, value='User written and gdialog generated') self.lbl_result = Label((10, 50), font=font10, fontcolor=WHITE, width=70, border=2, fgcolor=RED, bgcolor=DARKGREEN) # User written dialog fwdbutton(195, 242, UserDialogBox, text='User') # Dialog built using gdialog.py DialogBox dialog_elements = (('Yes', GREEN), ('No', RED), ('Foo', YELLOW)) fwdbutton(0, 242, DialogBox, text='Gen', args=(font14, ), kwargs={ 'elements': dialog_elements, 'label': 'Test dialog' }) quitbutton(390, 242)
def __init__(self): super().__init__() Label((0, 0), font=font14, value='plot module demo') Label((0, 200), font=font10, value='RT: simulate realtime data acquisition') fwdbutton(0, 242, PolarScreen, 'Polar') fwdbutton(100, 242, XYScreen, 'XY') fwdbutton(200, 242, RealtimeScreen, 'RT') quitbutton(390, 242)
def __init__(self): super().__init__() Label((0, 0), font = font14, value = 'plot module demo.') Label((0, 100), font = font10, value = 'RT: simulate realtime data acquisition.') Label((0, 140), font = font10, value = 'Over, Lines: test clipping.') fwdbutton(0, 242, PolarScreen, 'Polar') fwdbutton(100, 242, XYScreen, 'XY') fwdbutton(200, 242, RealtimeScreen, 'RT') fwdbutton(0, 200, PolarORScreen, 'Over') fwdbutton(100, 200, DiscontScreen, 'Lines') quitbutton(390, 242)
def __init__(self): super().__init__() Label((0, 0), font = font14, value = 'Green dial runs only') Label((0, 30), font = font14, value = 'when screen is visible') Label((0, 120), font = font14, value = "Yellow dial's value is") Label((0, 150), font = font14, value = 'computed continuously.') self.dial1 = Dial((350, 10), fgcolor = GREEN, border = 2, pointers = (0.9, 0.7)) self.dial2 = Dial((350, 120), fgcolor = YELLOW, border = 2, pointers = (0.9, 0.7)) self.pause = False # asyncio can't pause coros so handle at application level loop = asyncio.get_event_loop() loop.create_task(self.mainthread(self.dial1, True)) loop.create_task(self.mainthread(self.dial2)) fwdbutton(0, 242, BackScreen) backbutton(390, 242)
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'), } backbutton(390, 242) fwdbutton(0, 242, BackScreen) self.lstlbl = [] for n in range(3): self.lstlbl.append(Label((80 * n, 215), font = font10, **labels)) y = 5 self.slave1 = Slider((80, y), font = font10, fgcolor = GREEN, cb_end = self.callback, cbe_args = ('Slave1',), cb_move = self.slave_moved, cbm_args = (1,), **table) self.slave2 = Slider((160, y), font = font10, fgcolor = GREEN, cb_end = self.callback, cbe_args = ('Slave2',), cb_move = self.slave_moved, cbm_args = (2,), **table) master = Slider((0, y), font = font10, fgcolor = YELLOW, cb_end = self.callback, cbe_args = ('Master',), cb_move = self.master_moved, cbm_args = (0,), value=0.5, border = 2, **table)
def __init__(self): super().__init__() Label((0, 0), font=font14, value='Multiple screen demonstration.') fwdbutton(0, 242, KnobScreen, 'Knobs') fwdbutton(100, 242, SliderScreen, 'Sliders') fwdbutton(200, 242, AssortedScreen, 'Various') fwdbutton(0, 100, ThreadScreen, 'Threads') quitbutton(390, 242)
def __init__(self): super().__init__() Label((0, 0), font=font14, value='Green dial runs only') Label((0, 30), font=font14, value='when screen is visible') Label((0, 120), font=font14, value="Yellow dial's value is") Label((0, 150), font=font14, value='computed continuously.') self.dial1 = Dial((350, 10), fgcolor=GREEN, border=2, pointers=(0.9, 0.7)) self.dial2 = Dial((350, 120), fgcolor=YELLOW, border=2, pointers=(0.9, 0.7)) self.pid1 = Screen.objsched.add_thread(self.mainthread(self.dial1)) Screen.objsched.pause(self.pid1) Screen.objsched.add_thread(self.mainthread(self.dial2)) fwdbutton(0, 242, BackScreen) backbutton(390, 242)
def __init__(self): super().__init__() backbutton(390, 242) fwdbutton(0, 242, BackScreen) labels = { 'width': 70, 'fontcolor': WHITE, 'border': 2, 'fgcolor': RED, 'bgcolor': (0, 40, 0), } lstlbl = [] for n in range(2): lstlbl.append(Label((120, 120 + 40 * n), font=font10, **labels)) lbl_1 = Label((120, 120), font=font10, **labels) lbl_2 = Label((120, 160), font=font10, **labels) meter1 = Meter((320, 0), font=font10, legends=('0', '5', '10'), pointercolor=YELLOW, fgcolor=GREEN) dial1 = Dial((120, 0), fgcolor=YELLOW, border=2, pointers=(0.9, 0.7)) 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=[dial1, 0, lbl_1, meter1]) Knob((0, 120), fgcolor=WHITE, border=2, cb_move=self.knob_moved, cbm_args=[dial1, 1, lbl_2], cb_end=self.callback, cbe_args=['Knob2'], arc=pi * 1.5)
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__() Label((0, 0), font = font10, value = 'Ensure back refreshes properly') backbutton(390, 242)
def __init__(self): super().__init__() # Label common attributes labels = { 'width': 70, 'fontcolor': WHITE, 'border': 2, 'fgcolor': RED, 'bgcolor': (0, 40, 0), 'font': font14, } # Static labels Label((90, 0), font=font10, value='Flashing buttons') Label((90, 18), font=font10, value='(RH responds to long press)') Label((244, lr(1) + 5), font=font10, value='Reset radio button') Label((244, lr(2) + 5), font=font10, value='Reset checkbox') Label((244, lr(3) + 5), font=font10, value='Disable rb, checkbox') Label((370, 243), font=font14, value='Quit') # Dynamic labels self.lstlbl = [] for n in range(4): self.lstlbl.append(Label((400, lr(n)), **labels)) # Flashing buttons (RH one responds to long press) IconButton((10, lr(0)), icon_module=flash, flash=1.0, callback=self.callback, args=('A', 0)) IconButton((50, lr(0)), icon_module=flash, flash=1.0, callback=self.callback, args=('Short', 0), lp_callback=self.callback, lp_args=('Long', 0), onrelease=False) # Quit button IconButton((420, 240), icon_module=radiobutton, callback=self.quit) # Radio buttons rb = IconRadioButtons(callback=self.callback) rb0 = rb.add_button((10, lr(1)), icon_module=radiobutton, args=('1', 1)) rb.add_button((50, lr(1)), icon_module=radiobutton, args=('2', 1)) rb.add_button((90, lr(1)), icon_module=radiobutton, args=('3', 1)) rb.add_button((130, lr(1)), icon_module=radiobutton, args=('4', 1)) # Checkbox cb = IconButton((10, lr(2)), icon_module=threestate, toggle=True, callback=self.cbcb, args=(2, )) # Traffic light state change button IconButton((10, lr(4)), icon_module=traffic, toggle=True) # Reset buttons IconButton((200, lr(1)), icon_module=radiobutton, callback=self.rb_cancel, args=(rb, rb0)) IconButton((200, lr(2)), icon_module=radiobutton, callback=self.cb_cancel, args=(cb, )) # Switch sw = IconButton((10, lr(3)), icon_module=iconswitch, callback=self.cbswitch, toggle=True, args=(3, )) # Disable Checkbox IconButton((200, lr(3)), icon_module=checkbox, toggle=True, callback=self.cb_en_dis, args=((cb, rb, sw), )) # Gauge ig = IconGauge((80, lr(5)), icon_module=gauge) loop = asyncio.get_event_loop() loop.create_task(self.mainthread(ig))
def __init__(self): super().__init__() Label((0, 0), font=font14, value='Ensure back refreshes properly') backbutton(390, 242) self.open_arg = 'Opening' self.hide_arg = 'Hiding'
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,))