Esempio n. 1
0
 def __init__(self):
     height = 80
     width = 130
     super().__init__((20, 20), height, width, bgcolor=DARKGREEN)
     y = self.height - 30
     Button(self.locn(10, y),
            font=font10,
            fontcolor=BLACK,
            fgcolor=RED,
            text='Cat',
            callback=self.back,
            args=('Cat', ))
     Button(self.locn(70, y),
            font=font10,
            fontcolor=BLACK,
            fgcolor=GREEN,
            text='Dog',
            callback=self.back,
            args=('Dog', ))
     Button(self.locn(width - 21, 1),
            height=20,
            width=20,
            font=font10,
            fgcolor=RED,
            text='X',
            callback=self.back,
            args=('Close', ))
Esempio n. 2
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,))
Esempio n. 3
0
def quitbutton():
    def quit(button):
        Screen.shutdown()

    return Button((109, 107),
                  font=font10,
                  callback=quit,
                  fgcolor=RED,
                  text='Quit')
Esempio n. 4
0
 def __init__(self):
     super().__init__()
     self.cb1 = Checkbox((0, 0), callback = self.cbcb, args = (0,))
     self.cb2 = Checkbox((0, 30), fillcolor = RED, callback = self.cbcb, args = (1,))
     self.lstlbl = [Label((30, 0), **labels), Label((30, 30), **labels)]
     self.lbl_result = Label((0, 106), **labels)
     backbutton()
     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',))
Esempio n. 5
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, ))
Esempio n. 6
0
def fwdbutton(x, y, screen, text='Next'):
    def fwd(button, screen):
        Screen.change(screen)

    return Button((x, y),
                  font=font10,
                  fontcolor=BLACK,
                  callback=fwd,
                  args=[screen],
                  fgcolor=CYAN,
                  text=text)
Esempio n. 7
0
def backbutton():
    def back(button):
        Screen.back()

    return Button((139, 0),
                  font=font10,
                  fontcolor=BLACK,
                  callback=back,
                  fgcolor=RED,
                  text='X',
                  height=20,
                  width=20)
Esempio n. 8
0
def ovlbutton():
    def fwd(button):
        Screen.change(BackScreen)

    return Button((139, 35),
                  font=font10,
                  fontcolor=BLACK,
                  callback=fwd,
                  fgcolor=CYAN,
                  text='O',
                  height=20,
                  width=20)
Esempio n. 9
0
def clearbutton(graph):
    def clear(button):
        graph.clear()

    return Button((139, 71),
                  font=font10,
                  fontcolor=BLACK,
                  callback=clear,
                  fgcolor=GREEN,
                  text='C',
                  height=20,
                  width=20)
Esempio n. 10
0
def refreshbutton(curvelist):
    def refresh(button):
        for curve in curvelist:
            curve.show()

    return Button((139, 107),
                  font=font10,
                  fontcolor=BLACK,
                  callback=refresh,
                  fgcolor=GREEN,
                  text='R',
                  height=20,
                  width=20)
Esempio n. 11
0
    def __init__(self):
        super().__init__()
# tabulate data that varies between buttons
        table = [
            {'text' : 'F', 'args' : ('fwd',)},
            {'text' : 'B', 'args' : ('back',)},
            {'text' : 'U', 'args' : ('up',)},
            {'text' : 'D', 'args' : ('down',)},
        ]
        Label((0, 0), font = font10, value = 'Highlight Buttons')
# Highlighting buttons
        x = 0
        for t in table:
            Button((x, 30), shape = CIRCLE, fgcolor = GREY, fontcolor = BLACK, litcolor = WHITE,
                font = font10, callback = self.callback, height = 30, **t)
            x += 43
        self.lbl_result = Label((0, 106), **labels)
        backbutton()
Esempio n. 12
0
 def __init__(self):
     super().__init__()
     table = [
         {'text' : '1', 'args' : ('one',)},
         {'text' : '2', 'args' : ('two',)},
         {'text' : '3', 'args' : ('three',)},
         {'text' : '4', 'args' : ('four',)},
     ]
     Label((0, 0), font = font10, value = 'Radio Buttons')
     x = 0
     self.rb = RadioButtons(BLUE, self.callback) # color of selected button
     self.rb0 = None
     for t in table:
         button = self.rb.add_button((x, 30), shape = CIRCLE, font = font10, fontcolor = WHITE,
                             fgcolor = (0, 0, 90), height = 30, width = 30, **t)
         if self.rb0 is None: # Save for reset button callback
             self.rb0 = button
         x += 43
     self.lbl_result = Label((0, 106), **labels)
     backbutton()
     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',))
Esempio n. 13
0
    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,))
Esempio n. 14
0
def fwdbutton(x, y, cls_screen, *, text='Next', args=[], kwargs={}):
    def fwd(button):
        Screen.change(cls_screen, args=args, kwargs=kwargs)

    Button((x, y), font=font10, callback=fwd, fgcolor=RED, text=text)
Esempio n. 15
0
def fwdbutton(y, screen, text, color):
    def fwd(button, screen):
        Screen.change(screen)
    return Button((109, y), font = font10, fontcolor = BLACK, callback = fwd,
                  args = [screen], fgcolor = color, text = text)
Esempio n. 16
0
def backbutton():
    def back(button):
        Screen.back()
    Button((109, 107), font = font10, fontcolor = BLACK, callback = back,
           fgcolor = CYAN,  text = 'Back')
Esempio n. 17
0
def plotbutton(y, screen, color):
    def fwd(button, screen):
        Screen.change(screen)
    return Button((139, y), font = font10, fontcolor = BLACK, callback = fwd,
           args = [screen], fgcolor = color,  text = '~', height = 20, width = 20)