コード例 #1
0
class BaseScreen(Screen):
    def __init__(self):
        super().__init__()
        table_highlight = [
            {'text' : '1', 'args' : (HighlightScreen,)},
            {'text' : '2', 'args' : (RadioScreen,)},
            {'text' : '3', 'args' : (AssortedScreen,)},
            {'text' : '4', 'args' : (CheckboxScreen,)},
        ]
        quitbutton()
        Label((0, 0), font = font10, value = 'Choose screen')
        self.lst_en_dis = []
        x = 0
        for t in table_highlight:
            b = Button((x, 25), font = font10, shape = CIRCLE, fgcolor = BLUE,
                       fontcolor = BLACK, callback = self.callback,
                       height = 30, **t)
            self.lst_en_dis.append(b)
            x += 43
# 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 callback(self, button, screen):
        Screen.change(screen)

    def cb_en_dis(self, button, disable):
        for item in self.lst_en_dis:
            item.greyed_out(disable)
コード例 #2
0
    def __init__(self):
        super().__init__()
# Buttons
        backbutton()
        plotbutton(80, PlotScreen, YELLOW)
# Labels
        self.lbl_p = Label((0, 0), font = font10, width = 78, border = 2, bgcolor = DARKGREEN, fgcolor = RED)
        Label((90, 4), font = font10, value = 'Power')
        self.lbl_pmax = Label((0, 30), font = font10, width = 78, border = 2, bgcolor = DARKGREEN, fgcolor = RED)
        Label((90, 34), font = font10, value = 'Max')
        self.lbl_pin = Label((0, 55), font = font10, width = 78, border = 2, bgcolor = DARKGREEN, fgcolor = RED)
        self.lbl_pmin = Label((0, 80), font = font10, width = 78, border = 2, bgcolor = DARKGREEN, fgcolor = RED)
        Label((90, 84), font = font10, value = 'Min')
        self.lbl_w_hr = Label((0,105), font = font10, width = 78, border = 2, bgcolor = DARKGREEN, fgcolor = RED)
        self.lbl_t = Label((88, 105), font = font10, width = 70, border = 2, bgcolor = DARKGREEN, fgcolor = RED)

        table = [
            {'fgcolor' : GREEN, 'text' : 'Max Gen', 'args' : (True,)},
            {'fgcolor' : BLUE, 'text' : 'Mean', 'args' : (False,)},
        ]
        bl = ButtonList(self.buttonlist_cb)
        for t in table: # Buttons overlay each other at same location
            bl.add_button((90, 56), width = 70, font = font10, fontcolor = BLACK, **t)
        self.showmean = False
        self.t_reading = None  # Time of last reading
        self.t_start = None  # Time of 1st reading
        self.joules = 0  # Cumulative energy
        self.overrange = False
        self.wmax = 0  # Max power out
        self.wmin = 0  # Max power in
        self.pwr_min = 10000 # Power corresponding to minimum absolute value
コード例 #3
0
    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,))
コード例 #4
0
    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, ))
コード例 #5
0
 def __init__(self):
     super().__init__()
     labels = {
         'width': 50,
         'fontcolor': WHITE,
         'border': 2,
         'fgcolor': RED,
         'bgcolor': DARKGREEN,
         'font': font10,
     }
     quitbutton()
     self.meter = Meter((129, 0),
                        font=font6,
                        legends=('0', '5', '10'),
                        pointercolor=YELLOW,
                        fgcolor=CYAN)
     self.lbl_result = Label((25, 80), **labels)
     self.led = LED((0, 80), border=2)
     self.master = HorizSlider((0, 16),
                               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 = HorizSlider((0, 44),
                              fgcolor=GREEN,
                              cbe_args=('Slave', ),
                              cb_move=self.slave_moved,
                              border=2)
     loop = asyncio.get_event_loop()
     loop.create_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((0, 107),
                            font=font10,
                            fontcolor=BLACK,
                            fgcolor=GREEN,
                            text='Dis',
                            args=[True, lst_en_dis])
     button = bs.add_button((0, 107),
                            font=font10,
                            fontcolor=BLACK,
                            fgcolor=RED,
                            text='En',
                            args=[False, lst_en_dis])
コード例 #6
0
    def __init__(self):
        super().__init__()
        quitbutton()
        self.dial = Dial((106, 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((53, 0), fgcolor = WHITE, border = 2, arc = pi * 1.5,
                  cb_end = self.callback, cbe_args = ['Knob2'],
                  cb_move = self.knob_moved, cbm_args = (1,))

# On/Off toggle grey style
        self.lbl_style = Label((0, 80), font = font10, value = 'Current style: grey')
        bstyle = ButtonList(self.cb_style)
        bstyle.add_button((0, 107), font = font10, fontcolor = WHITE, fgcolor = RED,
                          text = 'Dim', args = (False,))
        bstyle.add_button((0, 107), font = font10, fontcolor = WHITE, fgcolor = GREEN,
                          text = 'Grey', args = (True,))
# On/Off toggle enable/disable
        bs = ButtonList(self.cb_en_dis)
        self.lst_en_dis = (bstyle, k0, k1)
        bs.add_button((53, 107), font = font10, fontcolor = BLACK, fgcolor = GREEN,
                      text = 'Dis', args = (True,))
        bs.add_button((53, 107), font = font10, fontcolor = BLACK, fgcolor = RED,
                      text = 'En', args = (False,))
コード例 #7
0
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())