예제 #1
0
def demo():
    chart = BarChart(10, 40, [fn, fn],
                     char="=",
                     gradient=[(20, Screen.COLOUR_GREEN),
                               (30, Screen.COLOUR_YELLOW),
                               (40, Screen.COLOUR_RED)])
    print(chart)
    chart = BarChart(13, 60,
                     [wv(1), wv(2), wv(3), wv(4), wv(5), wv(7), wv(8), wv(9)],
                     colour=Screen.COLOUR_GREEN,
                     axes=BarChart.BOTH,
                     scale=2.0)
    print(chart)
    chart = BarChart(7, 60, [lambda: time.time() * 10 % 101],
                     gradient=[(10, 234), (20, 236), (30, 238), (40, 240),
                               (50, 242), (60, 244), (70, 246), (80, 248),
                               (90, 250), (100, 252)],
                     char=">",
                     scale=100.0,
                     labels=True,
                     axes=BarChart.X_AXIS)
    print(chart)
    chart = BarChart(10, 60,
                     [wv(1), wv(2), wv(3), wv(4), wv(5), wv(7), wv(8), wv(9)],
                     colour=[c for c in range(1, 8)],
                     scale=2.0,
                     axes=BarChart.X_AXIS,
                     intervals=0.5,
                     labels=True,
                     border=False)
    print(chart)
예제 #2
0
def demo(screen):
    scenes = []
    if screen.width != 132 or screen.height != 24:
        effects = [
            Print(screen, FigletText("Resize to 132x24"),
                  y=screen.height//2-3),
        ]
    else:
        effects = [
            Print(screen,
                  BarChart(10, 40, [fn, fn],
                           char="=",
                           gradient=[(20, Screen.COLOUR_GREEN),
                                     (30, Screen.COLOUR_YELLOW),
                                     (40, Screen.COLOUR_RED)]),
                  x=13, y=1, transparent=False, speed=2),
            Print(screen,
                  BarChart(
                      13, 60,
                      [wv(1), wv(2), wv(3), wv(4), wv(5), wv(7), wv(8), wv(9)],
                      colour=Screen.COLOUR_GREEN,
                      axes=BarChart.BOTH,
                      scale=2.0),
                  x=68, y=1, transparent=False, speed=2),
            Print(screen,
                  BarChart(
                      7, 60, [lambda: time.time() * 10 % 101],
                      gradient=[
                          (33, Screen.COLOUR_RED, Screen.COLOUR_RED),
                          (66, Screen.COLOUR_YELLOW, Screen.COLOUR_YELLOW),
                          (100, Screen.COLOUR_WHITE, Screen.COLOUR_WHITE),
                      ] if screen.colours < 256 else [
                          (10, 234, 234), (20, 236, 236), (30, 238, 238),
                          (40, 240, 240), (50, 242, 242), (60, 244, 244),
                          (70, 246, 246), (80, 248, 248), (90, 250, 250),
                          (100, 252, 252)
                      ],
                      char=">",
                      scale=100.0,
                      labels=True,
                      axes=BarChart.X_AXIS),
                  x=68, y=16, transparent=False, speed=2),
            Print(screen,
                  BarChart(
                      10, 60,
                      [wv(1), wv(2), wv(3), wv(4), wv(5), wv(7), wv(8), wv(9)],
                      colour=[c for c in range(1, 8)],
                      bg=[c for c in range(1, 8)],
                      scale=2.0,
                      axes=BarChart.X_AXIS,
                      intervals=0.5,
                      labels=True,
                      border=False),
                  x=3, y=13, transparent=False, speed=2)
        ]

    scenes.append(Scene(effects, -1))
    screen.play(scenes, stop_on_resize=True)
예제 #3
0
    def test_bar_chart(self):
        """
        Check that the BarChart renderer works.
        """

        # Internal test function for rendering
        def fn():
            return 10

        # Check default implementation
        renderer = BarChart(7, 20, [fn, fn])
        self.assertEqual(
            str(renderer), "+------------------+\n" +
            "|                  |\n" + "|  |######         |\n" +
            "|  |               |\n" + "|  |######         |\n" +
            "|                  |\n" + "+------------------+")

        self.assertEqual(
            "\n".join(renderer.images[0]), "+------------------+\n" +
            "|                  |\n" + "|  |######         |\n" +
            "|  |               |\n" + "|  |######         |\n" +
            "|                  |\n" + "+------------------+")

        # Switch on non-defaults
        renderer = BarChart(5,
                            30, [fn, fn],
                            scale=10.0,
                            axes=BarChart.BOTH,
                            intervals=2.5,
                            labels=True,
                            border=False,
                            keys=["A", "B"])
        self.assertEqual(
            str(renderer), "A |########################## \n" +
            "  |      :      :     :       \n" +
            "B |########################## \n" +
            "  +------+------+-----+------ \n" +
            "   0    2.5    5.0   7.5 10.0 ")

        # Check gradients
        renderer = BarChart(7,
                            20, [fn, fn],
                            gradient=[(4, 1), (8, 2), (15, 2)])
        self.assertEqual(
            str(renderer), "+------------------+\n" +
            "|                  |\n" + "|  |######         |\n" +
            "|  |               |\n" + "|  |######         |\n" +
            "|                  |\n" + "+------------------+")
        self.assertEqual(renderer.rendered_text[1][2],
                         [(7, 2, 0), (None, 0, 0), (None, 0, 0), (7, 2, 0),
                          (1, 2, 0), (1, 2, 0), (2, 2, 0), (2, 2, 0),
                          (2, 2, 0), (2, 2, 0), (None, 0, 0), (None, 0, 0),
                          (None, 0, 0), (None, 0, 0), (None, 0, 0),
                          (None, 0, 0), (None, 0, 0), (None, 0, 0),
                          (None, 0, 0), (7, 2, 0)])
예제 #4
0
def demo(screen):
    #self._screen = screen
    scenes = []
    #Taille Rpi avec ecran 3,5" : 60x20
    message = "Resize to 60x20\nActual %sx%s" % (screen.width,screen.height)
    if screen.width != 60 or screen.height != 20:
        effects = [
            Print(screen, FigletText(message),
                  y=screen.height//2-3),
        ]
    else:
        # Rendu permettant l'affichage de l'horloge.
        renderClock = fxobdfiglet.FigletClock(screen.width, screen.height)
        renderExtTemp = fxobdfiglet.FigletExtTemp(screen.width, screen.height)
        renderRPM = fxobdfiglet.FigletRPM(screen.width, screen.height)
        
        #Creation de l'effet (inclusion de plusieurs rendus).
        effects = [
            #Ext Temperature
            Print(screen,
                  BarChart(5, 40, [wv(3)], char="=",
                       gradient=[(12, Screen.COLOUR_GREEN),
                                 (20, Screen.COLOUR_YELLOW),
                                 (24, Screen.COLOUR_RED)],
                       scale=24,
                       intervals=5,
                       labels=True),
                  x=5, y=1, transparent=False, speed=2),     
            Print(screen, FigletText("%s"%screen.width, font=u'lcd'),
                y=1, x= 40),
            #Engine temperature
            Print(screen,
                  BarChart(7, 40, [wv(2)],
                       char="=",
                       gradient=[(20, Screen.COLOUR_GREEN),
                                 (40, Screen.COLOUR_YELLOW),
                                 (60, Screen.COLOUR_RED)],
                       scale=80,
                       intervals=10,
                       labels=False),
                  x=5, y=5, transparent=False, speed=2),
            Print(screen, renderRPM, y=10, x= 40),
            #Affichage de la date et de l heure pb de rafraichissement il faut utiliser le fliglet dynamique.
            Print(screen, renderClock,
                  x=(screen.width)//2-renderClock.max_width, y= screen.height-1),
                  #x=(screen.width-wv(4).__len__())//2, y= screen.height-1),
        ]
    scenes.append(Scene(effects, -1))
    screen.play(scenes, stop_on_resize=True)
예제 #5
0
def demo(screen, scene):
    # scenes = [Scene([MainView(screen, datacache)], -1, name="Main Screen"),
    #           Scene([TimeView(screen, datacache, 0)], -1, name="P Screen"),
    #           Scene([TimeView(screen, datacache, 1)], -1, name="B Screen"),
    #           Scene([TimeView(screen, datacache, 2)], -1, name="L Screen")
    #           ]
    effect2 = Stars(screen, screen.width)
    effects = [
        Print(screen,
              BarChart(10,
                       40, [10, 10],
                       char="=",
                       gradient=[(20, Screen.COLOUR_GREEN),
                                 (30, Screen.COLOUR_YELLOW),
                                 (40, Screen.COLOUR_RED)]),
              x=13,
              y=1,
              transparent=False,
              speed=2)
    ]
    scenes2 = [Scene([MainView(screen, datacache)], -1, name="Main Screen")]
    scenes3 = [Scene([effect2], -1)]
    screen.play(scenes2,
                stop_on_resize=True,
                start_scene=scene,
                allow_int=True)
예제 #6
0
def ui(screen):
    scenes = []
    if screen.width != 70 or screen.height != 53:
        effects = [
            Print(screen,
                  FigletText("Resize to 70x53"),
                  y=screen.height // 2 - 3)
        ]
    else:
        effects = [
            Print(screen, FigletText("OptionsGAME"), y=0),
            Print(screen,
                  BarChart(8,
                           68, [wvc(9, 8), wv(9, 8)],
                           scale=100.0,
                           labels=True,
                           intervals=25.0,
                           border=False,
                           bg=[1, 2],
                           colour=[1, 2],
                           axes=BarChart.X_AXIS),
                  x=1,
                  y=7,
                  transparent=False,
                  speed=1),
            Print(screen,
                  BarChart(20,
                           68, [wv(7), wv(8), wv(9)],
                           char="x",
                           scale=100.0,
                           labels=True,
                           intervals=25.0,
                           axes=BarChart.X_AXIS,
                           gradient=[(50, Screen.COLOUR_GREEN),
                                     (75, Screen.COLOUR_YELLOW),
                                     (100, Screen.COLOUR_RED)]),
                  x=1,
                  y=15,
                  transparent=False,
                  speed=1)
        ]

    scenes.append(Scene(effects, -1))
    screen.play(scenes, stop_on_resize=True)
예제 #7
0
 def test_defaults(self):
     renderer = BarChart(7, 17, [fn(10), fn(5)])
     expected = ("╔═══════════════╗\n"
                 "║               ║\n"
                 "║  │##########  ║\n"
                 "║  │            ║\n"
                 "║  │#####       ║\n"
                 "║               ║\n"
                 "╚═══════════════╝")
     self.assertEqual(str(renderer), expected)
     self.assertEqual("\n".join(renderer.images[0]), expected)
예제 #8
0
    def test_styles(self):
        renderer = BarChart(7, 17, [fn(10), fn(5)])
        renderer.border_style = SINGLE_LINE
        self.assertEqual(
            str(renderer), "┌───────────────┐\n"
            "│               │\n"
            "│  │##########  │\n"
            "│  │            │\n"
            "│  │#####       │\n"
            "│               │\n"
            "└───────────────┘")

        renderer.border_style = ASCII_LINE
        renderer.axes_style = ASCII_LINE
        self.assertEqual(
            str(renderer), "+---------------+\n"
            "|               |\n"
            "|  |##########  |\n"
            "|  |            |\n"
            "|  |#####       |\n"
            "|               |\n"
            "+---------------+")
예제 #9
0
 def test_scale(self):
     renderer = BarChart(5,
                         41, [fn(5), fn(10)],
                         scale=10.0,
                         axes=BarChart.BOTH,
                         intervals=2.5,
                         labels=True,
                         border=False)
     self.assertEqual(
         str(renderer),
         # 1234567890123456789!12345678901234567890
         "│####################         │          \n" +
         "│         │         │         │          \n" +
         "│########################################\n" +
         "└─────────┴─────────┴─────────┴──────────\n" +
         " 0       2.5       5.0       7.5     10.0")
예제 #10
0
def demo(screen):
    scenes = []
    effects = [
        Print(screen,
              BarChart(5,
                       80, [get_volume],
                       char="=",
                       gradient=[(20, Screen.COLOUR_GREEN),
                                 (30, Screen.COLOUR_YELLOW),
                                 (40, Screen.COLOUR_RED)]),
              x=13,
              y=1,
              transparent=False,
              speed=2),
    ]

    scenes.append(Scene(effects, -1))
    screen.print_at("hihihihi", 10, 10)
    screen.play(scenes, stop_on_resize=True)
예제 #11
0
    def test_gradients(self):
        gradients = [
            (2, Screen.COLOUR_GREEN, Screen.COLOUR_BLUE),
            (4, Screen.COLOUR_YELLOW),
            (5, Screen.COLOUR_RED),
        ]

        renderer = BarChart(3,
                            5, [fn(5), fn(3), fn(1)],
                            border=False,
                            axes=BarChart.NO_AXIS,
                            gap=0,
                            gradient=gradients)

        self.assertEqual(
            renderer.rendered_text,
            (  #12345
                ['#####', '###  ', '#    '],
                [
                    [  # First bar colour sets
                        (2, 2, 4),  # 2 ticks of green with blue background
                        (2, 2, 4),
                        (3, 2, 0),  # 2 ticks of yellow with black background
                        (3, 2, 0),
                        (1, 2, 0)  # 1 tick of red with black background
                    ],
                    [  # Second bar colour sets
                        (2, 2, 4),  # 2 ticks of green with blue background
                        (2, 2, 4),
                        (3, 2, 0),  # 2 ticks of yellow with black background
                        (None, 0, 0),  # 2 ticks empty
                        (None, 0, 0),
                    ],
                    [  # Third bar colour sets
                        (2, 2, 4),  # 1 tick of green with blue background
                        (None, 0, 0),  # 4 ticks empty
                        (None, 0, 0),
                        (None, 0, 0),
                        (None, 0, 0),
                    ],
                ]))
예제 #12
0
    def prepare_display(self):
        # Effects are all the stuff which will be shown on the display
        # Speed 0 means: Redraw only when draw_next_frame is executed
        effects = [
            self.preset_frame, self.sender_frame,
            Print(self.screen, Box(80, 8, True), x=0, y=17, speed=0),
            Print(self.screen,
                  ColourImageFile(self.screen, LOGO, 9, bg=7),
                  x=0,
                  y=0,
                  speed=0),
            Print(self.screen,
                  FigletText(self.asciisierer(self.akt_sender_str)),
                  x=1,
                  y=18,
                  speed=0),
            Print(self.screen,
                  BarChart(4,
                           80, [self.get_vol],
                           colour=2,
                           char=' ',
                           bg=7,
                           scale=100,
                           axes=BarChart.X_AXIS,
                           intervals=25,
                           labels=True,
                           border=False),
                  x=0,
                  y=26,
                  transparent=False,
                  speed=0)
        ]

        # Start displaying
        self.scenes.append(Scene(effects, -1))
        self.screen.set_scenes(self.scenes)

        # Update the screen for the first time
        self.screen.draw_next_frame()
예제 #13
0
def demo(screen):
    scenes = []
    if screen.width != 132 or screen.height != 24:
        pass
    #     effects = [
    #         Print(screen, FigletText("Resize to 132x24"),
    #               y=screen.height//2-3),
    #     ]
    if True:
        effects = [
            Print(
                screen,
                BarChart(20,
                         40, [fn, fn, fn2],
                         char="d",
                         gradient=[(20, Screen.COLOUR_GREEN),
                                   (30, Screen.COLOUR_YELLOW),
                                   (40, Screen.COLOUR_RED)]),
                x=1,
                y=1,
                transparent=False,
                speed=2,
                delete_count=50,
            ),
            Matrix(screen, delete_count=50)
            # Clock(screen, x=10, y=10, r=10)
            # Print(screen,
            #       BarChart(
            #           13, 60,
            #           [wv(1), wv(2), wv(3), wv(4), wv(5), wv(7), wv(8), wv(9)],
            #           colour=Screen.COLOUR_GREEN,
            #           axes=BarChart.BOTH,
            #           scale=2.0),
            #       x=68, y=1, transparent=False, speed=2),
            # Print(screen,
            #       BarChart(
            #           7, 60, [lambda: time.time() * 10 % 101],
            #           gradient=[
            #               (33, Screen.COLOUR_RED, Screen.COLOUR_RED),
            #               (66, Screen.COLOUR_YELLOW, Screen.COLOUR_YELLOW),
            #               (100, Screen.COLOUR_WHITE, Screen.COLOUR_WHITE),
            #           ] if screen.colours < 256 else [
            #               (10, 234, 234), (20, 236, 236), (30, 238, 238),
            #               (40, 240, 240), (50, 242, 242), (60, 244, 244),
            #               (70, 246, 246), (80, 248, 248), (90, 250, 250),
            #               (100, 252, 252)
            #           ],
            #           char=">",
            #           scale=100.0,
            #           labels=True,
            #           axes=BarChart.X_AXIS),
            #       x=68, y=16, transparent=False, speed=2),
            # Print(screen,
            #       BarChart(
            #           10, 60,
            #           [wv(1), wv(2), wv(3), wv(4), wv(5), wv(7), wv(8), wv(9)],
            #           colour=[c for c in range(1, 8)],
            #           bg=[c for c in range(1, 8)],
            #           scale=2.0,
            #           axes=BarChart.X_AXIS,
            #           intervals=0.5,
            #           labels=True,
            #           border=False),
            #       x=3, y=13, transparent=False, speed=2)
        ]
    # if time.time() - start < delta:

    scenes.append(Scene(effects))
    screen.play(scenes, stop_on_resize=True)
예제 #14
0
def graphs(screen):
    global simulation
    #    global moneyFunctions
    names = [table.players[0].name for table in simulation.tables]
    money = Print(
        screen,
        BarChart(
            14,
            100,
            [money0, money1, money2],
            #              BarChart(14, 100, moneyFunctions,
            char="=",
            gradient=[(STARTING_MONEY / 4, Screen.COLOUR_RED),
                      (STARTING_MONEY / 4 * 3, Screen.COLOUR_YELLOW),
                      (STARTING_MONEY, Screen.COLOUR_WHITE),
                      (MAX_MONEY, Screen.COLOUR_GREEN)],
            scale=MAX_MONEY,
            labels=True,
            axes=BarChart.X_AXIS,
            intervals=MAX_MONEY / 4,
            keys=names),
        x=3,
        y=2,
        transparent=False,
        speed=1)

    won = Print(screen,
                BarChart(14,
                         25, [won0, won1, won2],
                         char="W",
                         keys=names,
                         labels=True,
                         axes=BarChart.X_AXIS,
                         intervals=MAX_WON,
                         scale=MAX_WON),
                x=3,
                y=20,
                transparent=False,
                speed=1)

    lost = Print(screen,
                 BarChart(14,
                          15, [lost0, lost1, lost2],
                          char="L",
                          labels=True,
                          axes=BarChart.X_AXIS,
                          intervals=MAX_LOST,
                          scale=MAX_LOST),
                 x=33,
                 y=20,
                 transparent=False,
                 speed=1)

    pushed = Print(screen,
                   BarChart(14,
                            15, [pushed0, pushed1, pushed2],
                            char="P",
                            labels=True,
                            axes=BarChart.X_AXIS,
                            intervals=MAX_PUSH,
                            scale=MAX_PUSH),
                   x=53,
                   y=20,
                   transparent=False,
                   speed=1)

    scenes = []
    scenes.append(Scene([money, lost, pushed], duration=200))
    #    scenes.append(Scene([money, won, lost, pushed], duration=50))
    while simulation.has_players():
        screen.play(scenes, repeat=False)
예제 #15
0
    def test_args_no_scale(self):
        renderer = BarChart(3,
                            10, [fn(10), fn(5)],
                            char='=',
                            border=False,
                            axes=BarChart.NO_AXIS)
        self.assertEqual(str(renderer),
                         "==========\n" + "          \n" + "=====     ")

        renderer = BarChart(7,
                            16, [fn(10), fn(5)],
                            char='=',
                            axes=BarChart.NO_AXIS)
        self.assertEqual(
            str(renderer), "╔══════════════╗\n"
            "║              ║\n"
            "║  ==========  ║\n"
            "║              ║\n"
            "║  =====       ║\n"
            "║              ║\n"
            "╚══════════════╝")

        renderer = BarChart(7,
                            17, [fn(10), fn(5)],
                            char='=',
                            axes=BarChart.Y_AXIS)
        self.assertEqual(
            str(renderer), "╔═══════════════╗\n"
            "║               ║\n"
            "║  │==========  ║\n"
            "║  │            ║\n"
            "║  │=====       ║\n"
            "║               ║\n"
            "╚═══════════════╝")

        renderer = BarChart(8,
                            17, [fn(10), fn(5)],
                            char='=',
                            axes=BarChart.BOTH)
        self.assertEqual(
            str(renderer), "╔═══════════════╗\n"
            "║               ║\n"
            "║  │==========  ║\n"
            "║  │            ║\n"
            "║  │=====       ║\n"
            "║  └──────────  ║\n"
            "║               ║\n"
            "╚═══════════════╝")

        renderer = BarChart(8,
                            21, [fn(10), fn(5)],
                            char='=',
                            axes=BarChart.BOTH,
                            keys=['a', 'bbb'])
        self.assertEqual(
            str(renderer), "╔═══════════════════╗\n"
            "║                   ║\n"
            "║    a │==========  ║\n"
            "║      │            ║\n"
            "║  bbb │=====       ║\n"
            "║      └──────────  ║\n"
            "║                   ║\n"
            "╚═══════════════════╝")

        renderer = BarChart(9,
                            21, [fn(10), fn(5)],
                            char='=',
                            axes=BarChart.BOTH,
                            keys=['a', 'bbb'],
                            labels=True)
        self.assertEqual(
            str(renderer), "╔═══════════════════╗\n"
            "║                   ║\n"
            "║    a │==========  ║\n"
            "║      │            ║\n"
            "║  bbb │=====       ║\n"
            "║      └──────────  ║\n"
            "║       0       10  ║\n"
            "║                   ║\n"
            "╚═══════════════════╝")

        renderer = BarChart(9,
                            21, [fn(10), fn(4)],
                            char='=',
                            axes=BarChart.BOTH,
                            keys=['a', 'bbb'],
                            labels=True,
                            intervals=5)
        self.assertEqual(
            str(renderer), "╔═══════════════════╗\n"
            "║                   ║\n"
            "║    a │==========  ║\n"
            "║      │    │       ║\n"
            "║  bbb │====│       ║\n"
            "║      └────┴─────  ║\n"
            "║       0   5   10  ║\n"
            "║                   ║\n"
            "╚═══════════════════╝")

        renderer = BarChart(8,
                            21, [fn(10), fn(4)],
                            char='=',
                            axes=BarChart.BOTH,
                            keys=['a', 'bbb'],
                            labels=True,
                            intervals=5,
                            gap=0)
        self.assertEqual(
            str(renderer), "╔═══════════════════╗\n"
            "║                   ║\n"
            "║    a │==========  ║\n"
            "║  bbb │====│       ║\n"
            "║      └────┴─────  ║\n"
            "║       0   5   10  ║\n"
            "║                   ║\n"
            "╚═══════════════════╝")
예제 #16
0
def demo(screen):
    scenes = []
    if screen.width != 132 or screen.height != 24:
        effects = [
            Print(screen,
                  FigletText("Resize to 132x24"),
                  y=screen.height // 2 - 3),
        ]
    else:
        # Horizontal Charts
        hchart1 = BarChart(
            9,
            22,
            [fn, fn],
            char="═",
            gradient=[(7, Screen.COLOUR_GREEN), (9, Screen.COLOUR_YELLOW),
                      (10, Screen.COLOUR_RED)],
            keys=["one", "two"],
            gap=1,
        )
        hchart2 = BarChart(
            10,
            25, [wv(1), wv(3), wv(5), wv(7), wv(9)],
            colour=Screen.COLOUR_GREEN,
            axes=BarChart.BOTH,
            scale=2.0)
        hchart2.border_style = ASCII_LINE
        hchart2.axes_style = ASCII_LINE
        hchart3 = BarChart(
            10,
            40, [wv(1), wv(2),
                 wv(3), wv(4),
                 wv(5), wv(7),
                 wv(8), wv(9)],
            colour=[c for c in range(1, 8)],
            bg=[c for c in range(1, 8)],
            scale=2.0,
            axes=BarChart.X_AXIS,
            intervals=0.5,
            labels=True,
            border=False)
        hchart4 = BarChart(7,
                           30, [lambda: time.time() * 10 % 101],
                           gradient=[
                               (33, Screen.COLOUR_RED, Screen.COLOUR_RED),
                               (66, Screen.COLOUR_YELLOW,
                                Screen.COLOUR_YELLOW),
                               (100, Screen.COLOUR_WHITE, Screen.COLOUR_WHITE),
                           ] if screen.colours < 256 else [(10, 234, 234),
                                                           (20, 236, 236),
                                                           (30, 238, 238),
                                                           (40, 240, 240),
                                                           (50, 242, 242),
                                                           (60, 244, 244),
                                                           (70, 246, 246),
                                                           (80, 248, 248),
                                                           (90, 250, 250),
                                                           (100, 252, 252)],
                           char=">",
                           scale=100.0,
                           labels=True,
                           axes=BarChart.X_AXIS)
        hchart4.border_style = SINGLE_LINE

        # Vertical Charts
        vchart1 = VBarChart(
            12,
            21,
            [fn2, fn2],
            char="═",
            gradient=[(3, Screen.COLOUR_GREEN), (4, Screen.COLOUR_YELLOW),
                      (5, Screen.COLOUR_RED)],
            keys=["one", "two"],
        )
        vchart2 = VBarChart(
            12,
            17, [wv(1), wv(3), wv(5), wv(7), wv(9)],
            colour=Screen.COLOUR_GREEN,
            axes=BarChart.BOTH,
            scale=2.0,
            gap=0)
        vchart2.border_style = ASCII_LINE
        vchart2.axes_style = ASCII_LINE
        vchart3 = VBarChart(
            12,
            39, [wv(1), wv(2),
                 wv(3), wv(4),
                 wv(5), wv(7),
                 wv(8), wv(9)],
            colour=[c for c in range(1, 8)],
            bg=[c for c in range(1, 8)],
            gap=0,
            scale=2.0,
            axes=BarChart.Y_AXIS,
            intervals=0.5,
            labels=True,
            border=False)
        vchart4 = VBarChart(12,
                            16, [lambda: time.time() * 10 % 101],
                            gradient=[
                                (33, Screen.COLOUR_RED, Screen.COLOUR_RED),
                                (66, Screen.COLOUR_YELLOW,
                                 Screen.COLOUR_YELLOW),
                                (100, Screen.COLOUR_WHITE,
                                 Screen.COLOUR_WHITE),
                            ] if screen.colours < 256 else [(10, 234, 234),
                                                            (20, 236, 236),
                                                            (30, 238, 238),
                                                            (40, 240, 240),
                                                            (50, 242, 242),
                                                            (60, 244, 244),
                                                            (70, 246, 246),
                                                            (80, 248, 248),
                                                            (90, 250, 250),
                                                            (100, 252, 252)],
                            char=">",
                            scale=100.0,
                            labels=True,
                            axes=VBarChart.Y_AXIS)
        vchart4.border_style = SINGLE_LINE

        effects = [
            Print(screen, hchart1, x=1, y=1, transparent=False, speed=2),
            Print(screen, hchart2, x=25, y=1, transparent=False, speed=2),
            Print(screen, hchart3, x=52, y=1, transparent=False, speed=2),
            Print(screen, hchart4, x=96, y=2, transparent=False, speed=2),
            Print(screen, vchart1, x=2, y=12, transparent=False, speed=2),
            Print(screen, vchart2, x=29, y=12, transparent=False, speed=2),
            Print(screen, vchart3, x=52, y=12, transparent=False, speed=2),
            Print(screen, vchart4, x=103, y=12, transparent=False, speed=2),
        ]

    scenes.append(Scene(effects, -1))
    screen.play(scenes, stop_on_resize=True)
예제 #17
0
파일: asciio.py 프로젝트: dasteihn/visio
def demo(screen):
    scenes = []
    preset_frame = Frame(screen,
                         11,
                         26,
                         can_scroll=False,
                         title="Tastenbelegung",
                         x=SF_X,
                         y=SF_Y,
                         reduce_cpu=True)
    pr_layout = Layout([10, 90], fill_frame=True)
    preset_frame.add_layout(pr_layout)

    sender_frame = Frame(screen,
                         11,
                         26,
                         can_scroll=False,
                         title="Senderliste",
                         x=27,
                         y=6,
                         reduce_cpu=True)
    sender_layout0 = Layout([10, 90, 10], fill_frame=True)

    sender_frame.add_layout(sender_layout0)

    optionen = [(" ", 1), ("Zweiter", 2), ("Dritter", 3), ("Vierter", 4),
                ("Deutschlandradio", 5), ("Absolut Relax", 6), ("Siebter", 7),
                ("hmm", 8)]

    sender = [
        "123456789012345678901", "Erster", "Zweiter", "Dritter", "Vierter",
        "Fünfter", "Sechster"
    ]
    Senderkiste = ListBox(8, optionen, False)
    sender_layout0.add_widget(Senderkiste, 1)
    Senderkiste.blur()
    Senderkiste.start_line = 1

    format_sl_layout(sender_layout0)
    # format_pr_layout(pr_layout)
    for i, s in zip(range(1, 6), sender):
        pr_layout.add_widget(Label(str(i), 1, align=u'^'))
        pr_layout.add_widget(Label(s, 1, align='^'), 1)

    preset_frame.fix()
    sender_frame.fix()

    effects = [
        preset_frame,
        sender_frame,
        Print(screen, Box(26, 15, True), x=UHR_K_X, y=UHR_K_Y),
        Print(screen, Box(80, 8, True), x=0, y=17),
        Clock(screen, 67, 7, 6),
        Print(screen, FigletText("Retroradio!"), x=0, y=0),
        #            Print(screen, BarChart(4, 80, [get_vol], colour=2, scale=100,
        #                axes=BarChart.X_AXIS, intervals=25, labels=True, border=False), x=0, y=26,
        #                transparent=False),
        # Print(screen, SpeechBubble("Lautstärke"), x=0, y=23),
        Print(screen, FigletText("Deutschlandradio"), x=1, y=18),
        Print(screen,
              BarChart(4,
                       80, [get_vol],
                       colour=2,
                       char=' ',
                       bg=7,
                       scale=100,
                       axes=BarChart.X_AXIS,
                       intervals=25,
                       labels=True,
                       border=False),
              x=0,
              y=26,
              transparent=False,
              speed=2)
    ]

    scenes.append(Scene(effects, -1))
    screen.play(scenes)
예제 #18
0
def run_display(screen):
    scenes = []
    AKT_SENDER = "Retro rockt!"

    # Prepare frame for the presets
    preset_frame = Frame(screen,
                         7,
                         29,
                         can_scroll=False,
                         title="Tastenbelegung",
                         x=0,
                         y=10,
                         reduce_cpu=True)
    pr_layout = Layout([10, 90], fill_frame=True)
    preset_frame.add_layout(pr_layout)

    # Prepare frame for the sender list
    sender_frame = Frame(screen,
                         17,
                         50,
                         can_scroll=False,
                         title="Senderliste",
                         x=30,
                         y=0,
                         reduce_cpu=True)
    sender_layout0 = Layout([10, 80, 10], fill_frame=True)
    sender_frame.add_layout(sender_layout0)

    # Load the json config-file
    cfg = load_config()

    # Prepare the layouts, add spaces etc
    format_sl_layout(sender_layout0)

    # Nicht mehr nötig nach aktuellem Stand
    # format_pr_layout(pr_layout)

    # Create the sender-labels and fill them initially. Return them for
    # later changing
    sender_labels = gen_and_add_sender_labels(sender_layout0,
                                              parse_sender(cfg, 0))
    preset_labels = gen_and_add_preset_labels(pr_layout, parse_presets(cfg))

    preset_frame.fix()
    sender_frame.fix()

    # Effects are all the stuff which will be shown on the display
    effects = [
        preset_frame,
        sender_frame,
        # Print(screen, Box(26, 15, True), x=54, y=0),
        Print(screen, Box(80, 8, True), x=0, y=17, speed=2),
        # Clock(screen, 68, 7, 5),
        Print(screen,
              ColourImageFile(screen, LOGO, 9, bg=7),
              x=0,
              y=0,
              speed=2),
        Print(screen, FigletText(asciisierer(AKT_SENDER)), x=1, y=18),
        Print(screen,
              BarChart(4,
                       80, [get_vol],
                       colour=2,
                       char=' ',
                       bg=7,
                       scale=100,
                       axes=BarChart.X_AXIS,
                       intervals=25,
                       labels=True,
                       border=False),
              x=0,
              y=26,
              transparent=False,
              speed=2)
    ]

    # Start displaying
    scenes.append(Scene(effects, -1))
    screen.play(scenes)