Exemplo n.º 1
0
def demo(screen):
    scenes = []
    effects = [
        Print(screen,
              FigletText("JOGET BRO",
                         font='banner3' if screen.width > 80 else 'banner'),
              screen.height//2-3,
              colour=7, bg=7 if screen.unicode_aware else 0),
    ]
    scenes.append(Scene(effects))
    effects = [
        Print(screen,
              ColourImageFile(screen, "joget.gif", screen.height,
                              uni=screen.unicode_aware),
              screen.height,
              speed=1),
        Scroll(screen, 2)
    ]
    scenes.append(Scene(effects))
    effects = [
        BannerText(screen,
                   ColourImageFile(screen, "joget.gif", screen.height-2,
                                   uni=screen.unicode_aware, dither=screen.unicode_aware),
                   0, 0),
    ]
    scenes.append(Scene(effects))
    effects = [
        Print(screen,
              FigletText("THANKS",
                         font='banner3' if screen.width > 80 else 'banner'),
              screen.height//2-3,
              colour=7, bg=7 if screen.unicode_aware else 0),
    ]
    scenes.append(Scene(effects))
    screen.play(scenes, stop_on_resize=True)
Exemplo n.º 2
0
def demo(screen):
    scenes = []
    effects = [
        Print(screen,
              ColourImageFile(screen, "colour_globe.gif", screen.height - 2),
              0,
              stop_frame=200),
        Print(screen,
              FigletText("ASCIIMATICS NEWS", font='banner3'),
              screen.height // 2 - 3,
              colour=7),
    ]
    scenes.append(Scene(effects))
    effects = [
        Print(screen,
              ColourImageFile(screen, "grumpy_cat.jpg", 40),
              screen.height,
              stop_frame=(40 + screen.height) * 3),
        Scroll(screen, 3)
    ]
    scenes.append(Scene(effects))
    effects = [
        BannerText(screen,
                   ColourImageFile(screen, "python.png", screen.height - 2), 0,
                   0),
    ]
    scenes.append(Scene(effects))

    screen.play(scenes, stop_on_resize=True)
Exemplo n.º 3
0
 def load_image(self, screen, filename):
     self.images[filename] = [None, None]
     self.images[filename][0] = ColourImageFile(screen,
                                                filename,
                                                IMAGE_HEIGHT,
                                                uni=False)
     self.images[filename][1] = ColourImageFile(screen,
                                                filename,
                                                IMAGE_HEIGHT,
                                                uni=True)
Exemplo n.º 4
0
        def internal_checks(screen):
            # Check the original FG only rendering
            renderer = ColourImageFile(
                screen,
                os.path.join(os.path.dirname(__file__), "globe.gif"),
                height=10)

            # Check renderer got all images from the file.
            count = 0
            for image in renderer.images:
                count += 1
                self.assertIsNotNone(image)
                self.assertIsNotNone(len(image) <= renderer.max_height)
            self.assertEqual(count, 11)

            # Check an image looks plausible
            image = next(renderer.images)
            self.maxDiff = None
            self.assertEqual(
                image,
                ['',
                 '     ##########     ',
                 '  ###############   ',
                 ' ################## ',
                 '####################',
                 '####################',
                 '####################',
                 '################### ',
                 ' #################  ',
                 '   ##############   ',
                 '      #######       '])

            # Also check the BG rendering
            renderer2 = ColourImageFile(
                screen,
                os.path.join(os.path.dirname(__file__), "globe.gif"),
                fill_background=True,
                height=10)

            # Check BG rendering doesn't change the visible text output.
            # Note that BG rendering needs to print dots for some terminals.
            image2 = [x.replace(".", " ") for x in next(renderer2.images)]
            self.assertEqual(image, image2)

            # Check BG rendering gives same colours for FG and BG as original
            # rendering
            for a, b in zip(renderer.rendered_text[1],
                            renderer2.rendered_text[1]):
                for attr1, attr2 in zip(a, b):
                    if attr1[0] is None:
                        self.assertEqual(0, attr2[0])
                        self.assertEqual(0, attr2[2])
                    else:
                        self.assertEqual(attr1[0], attr2[0])
                        self.assertEqual(attr2[0], attr2[2])
Exemplo n.º 5
0
def demo(screen):
    scenes = []
    effects = [
        Print(screen,
              ImageFile("globe.gif", screen.height - 2,
                        colours=screen.colours),
              0,
              stop_frame=100),
    ]
    scenes.append(Scene(effects))
    effects = [
        Print(screen,
              ColourImageFile(screen,
                              "colour_globe.gif",
                              screen.height - 2,
                              uni=screen.unicode_aware,
                              dither=screen.unicode_aware),
              0,
              stop_frame=200),
        Print(screen,
              FigletText("ASCIIMATICS",
                         font='banner3' if screen.width > 80 else 'banner'),
              screen.height // 2 - 3,
              colour=7,
              bg=7 if screen.unicode_aware else 0),
    ]
    scenes.append(Scene(effects))
    effects = [
        Print(screen,
              ColourImageFile(screen,
                              "grumpy_cat.jpg",
                              screen.height,
                              uni=screen.unicode_aware),
              screen.height,
              speed=1,
              stop_frame=(40 + screen.height) * 3),
        Scroll(screen, 3)
    ]
    scenes.append(Scene(effects))
    effects = [
        BannerText(
            screen,
            ColourImageFile(screen,
                            "python.png",
                            screen.height - 2,
                            uni=screen.unicode_aware,
                            dither=screen.unicode_aware), 0, 0),
    ]
    scenes.append(Scene(effects))

    screen.play(scenes, stop_on_resize=True)
Exemplo n.º 6
0
        def internal_checks(screen):
            # Check the original FG only rendering
            renderer = ColourImageFile(screen,
                                       os.path.join(os.path.dirname(__file__),
                                                    "globe.gif"),
                                       height=10,
                                       uni=True,
                                       dither=True)

            # Check renderer got all images from the file.
            count = 0
            for image in renderer.images:
                count += 1
                self.assertIsNotNone(image)
                self.assertIsNotNone(len(image) <= renderer.max_height)
            self.assertEqual(count, 11)

            # Check an image looks plausible
            image = next(renderer.images)
            self.assertEqual(image, [
                '.', '.....▄▄▄▄▄▄▄▄▄▄......', '...▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄...',
                '.▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄..', '.▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄.',
                '▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄.', '▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄.',
                '.▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄.', '.▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄..',
                '...▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄...', '.....▄▄▄▄▄▄▄▄▄▄▄.....'
            ])
Exemplo n.º 7
0
    def _context_changed(self, e: PropertyChangedEventArgs):
        if e.property_name == "image":
            if self._image is not None:
                self._scene.remove_effect(self._image)
                self._image = None

            if isinstance(self._data_context.image, HTTPError):
                err: HTTPError = self._data_context.image
                msg = str(err.code) + "\n" + err.reason
                self._scene.add_effect(
                    PopUpDialog(self._screen,
                                msg, ["Close"],
                                on_close=self._back,
                                theme="user_theme"))
            elif isinstance(self._data_context.image, URLError):
                err: URLError = self._data_context.image
                self._scene.add_effect(
                    PopUpDialog(self._screen,
                                str(err.reason), ["Close"],
                                on_close=self._back,
                                theme="user_theme"))
            else:
                self._image = Print(
                    self.screen,
                    ColourImageFile(self._screen,
                                    self._data_context.image,
                                    height=self._screen.height), -1)
                self._scene.add_effect(self._image)
Exemplo n.º 8
0
 def _seq(self, screen, scene):
     scenes = []
     banner_pos = (screen.width - 100) // 2 + 20
     static_image = [
         Print(screen,
               ColourImageFile(screen,
                               op.join(DIRNAME, "assets", "images",
                                       "ibm1620.jpg"),
                               screen.height,
                               uni=screen.unicode_aware),
               y=0,
               speed=1,
               stop_frame=(21 + screen.height) * 2),
         Print(screen,
               FigletText("PyPadberg", "banner"),
               screen.height - 8,
               x=banner_pos,
               colour=Screen.COLOUR_BLACK,
               bg=Screen.COLOUR_BLACK,
               speed=1),
         Print(screen,
               FigletText("PyPadberg", "banner"),
               screen.height - 9,
               x=(banner_pos + 1),
               colour=Screen.COLOUR_WHITE,
               bg=Screen.COLOUR_WHITE,
               speed=1),
     ]
     scenes.append(Scene(static_image, name="intro2"))
     scenes.append(Scene([TextFormFrame(screen)], -1, name="text_entry"))
     scenes.append(
         Scene([ProcessingFrame(screen)], -1, name="display_processing"))
     final_frame = [Julia(screen), FinalFrame(screen)]
     scenes.append(Scene(final_frame, -1, name="end_menu"))
     screen.play(scenes, stop_on_resize=True, start_scene=scene)
Exemplo n.º 9
0
def fetchImage(screen, ex):
    if pathlib.Path(r'CurrentImg.png').exists():
        image = ColourImageFile(screen, r'CurrentImg.png', height=screen.height)
    else:
        image = FigletText(text='NO CURRENT IMAGE')
    eff = [Print(screen, image, y=0)]
    eff.extend(ex)
    screen.play([Scene(eff)])
Exemplo n.º 10
0
 def _print_element(self, screen: Screen):
     return ColourImageFile(
         screen,
         self.obj["src"],
         self.size,
         fill_background=True,
         uni=screen.unicode_aware,
         dither=screen.unicode_aware,
     )
Exemplo n.º 11
0
	def color(self, screen = None, file = None,):
		if file == None:
			file = self.imgs[0]

		scenes = []
		effects = [
			Print(screen,
				ColourImageFile(screen, file, screen.height, uni = screen.unicode_aware, dither = screen.unicode_aware),
				screen.height),
			Scroll(screen, 2)
		]
		scenes.append(Scene(effects))
		screen.play(scenes)
Exemplo n.º 12
0
def _image(screen, element, row, bg_color):
    image = Print(
        screen,
        ColourImageFile(
            screen,
            element.obj["src"],
            element.size,
            bg=bg_color,
            fill_background=True,
            uni=screen.unicode_aware,
            dither=screen.unicode_aware,
        ),
        row,
    )

    return [image]
Exemplo n.º 13
0
    def reset(self, old_scene=None, screen=None):
        image_filename = pkg_resources.resource_filename(pkg_resources.Requirement.parse('writer'), f"writer/art/{self._imagefile}")
        effects = [
            Print(self._screen, ColourImageFile(self._screen, image_filename, self._screen.height, bg=Screen.COLOUR_BLACK,
                  fill_background=False, uni=False, dither=False),
                  0,
                  stop_frame=100),

            Print(self._screen,
                  BW(self._screen, FigletText(self._imagetext, font=self._font, width=self._screen.width-14)),
                  x=4, y=8,
                  clear=True,
                  start_frame=0,
                  stop_frame=200)
                  ]
        for fx in effects:
            self.add_effect(fx)
Exemplo n.º 14
0
 def _get_satellite_tile(self, x_tile, y_tile, z_tile):
     """Load up a single satellite image tile."""
     cache_file = "mapscache/{}.{}.{}.jpg".format(z_tile, x_tile, y_tile)
     if cache_file not in self._tiles:
         if not os.path.isfile(cache_file):
             url = _IMAGE_URL.format(z_tile, x_tile, y_tile, _KEY)
             data = requests.get(url).content
             with open(cache_file, 'wb') as f:
                 f.write(data)
         self._tiles[cache_file] = [
             x_tile, y_tile, z_tile,
             ColourImageFile(self._screen, cache_file, height=_START_SIZE, dither=True,
                             uni=self._screen.unicode_aware),
             True]
         if len(self._tiles) > _CACHE_SIZE:
             self._tiles.popitem(False)
         self._screen.force_update()
Exemplo n.º 15
0
def main(screen, args):

    os.environ['GYM_NEYBOY_OBS_AS_BYTES'] = '1'
    del os.environ['GYM_NEYBOY_ENV_NON_HEADLESS']

    env = gym.make(args.env)
    total_reward = 0
    total_steps = 0
    while True:
        total_steps += 1
        ev = screen.get_key()
        action = 0

        if ev in (Screen.KEY_LEFT, ord('A'), ord('a')):
            action = 1
        elif ev in (Screen.KEY_RIGHT, ord('D'), ord('d')):
            action = 2
        elif ev in (Screen.KEY_UP, ord('W'), ord('w')):
            env.reset()
        elif ev in (Screen.KEY_ESCAPE, ord('Q'), ord('q')):
            env.close()
            break

        observation, reward, done, info = env.step(action)
        total_reward += reward

        if args.color:
            renderer = ColourImageFile(screen, observation, height=args.height)
        else:
            renderer = ImageFile(observation,
                                 height=args.height,
                                 colours=screen.colours)

        image, colours = renderer.rendered_text
        for (i, line) in enumerate(image):
            screen.centre(line, i, colour_map=colours[i])

        screen.print_at('{0:.2f}'.format(reward), 0, 0)
        screen.print_at('{0:.2f}'.format(total_reward), 0, 1)
        screen.print_at('done: {}'.format(done), 0, 2)

        screen.refresh()
Exemplo n.º 16
0
    def __init__(self, screen, recipe):
        name = recipe['title']
        image_url = recipe['image']
        self.missed_ingredients = recipe['missedIngredients']
        self.recipie_id = recipe['id']
        used_ingredients = recipe['usedIngredients']
        super(Recipie, self).__init__(screen,
                                      int(screen.height) - 10,
                                      int(screen.width // 2),
                                      x=(int(screen.width // 2) - 5),
                                      has_shadow=True)
        layout = Layout([1])
        self.add_layout(layout)
        layout.add_widget(Label(name, align='^', height=2), 0)
        layout.add_widget(Divider(height=1), 0)

        layout2 = Layout([1, 1])
        self.add_layout(layout2)
        layout2.add_widget(Label("Used Ingrediants", height=2), 0)
        for used_ingredient in used_ingredients:
            layout2.add_widget(Label(f"   - {used_ingredient['name']}"), 0)
        layout2.add_widget(Label("", height=1), 0)
        layout2.add_widget(
            Label("Ingrediants Required From the Groccery Store", height=2), 0)
        for missed_ingredient in self.missed_ingredients:
            layout2.add_widget(Label(f"   - {missed_ingredient['name']}"), 0)
        layout2.add_widget(Label("", height=1), 0)

        self.image_name = self._download_image(image_url)
        image = Print(screen,
                      ColourImageFile(screen, self.image_name),
                      x=5,
                      y=5)
        self.add_effect(image)

        layout3 = Layout([1, 1, 1])
        self.add_layout(layout3)
        layout3.add_widget(Button("Don't Add And Continue", self._dont_add), 0)
        layout3.add_widget(Button("Add and Continue", self._add), 1)
        layout3.add_widget(Button("Quit", self._quit), 2)
        self.fix()
Exemplo n.º 17
0
def main(screen, args):
    home_dir = Path.home()
    data_dir = Path(home_dir, 'flappybird')
    data_dir.mkdir(exist_ok=True)

    game = SyncFlappyBird.create(headless=not args.non_headless,
                                 user_data_dir=str(data_dir))
    game.load()

    while True:
        state = game.get_state(include_snapshot='bytes')
        ev = screen.get_key()
        if ev in (Screen.KEY_LEFT, ord('A'), ord('a'), Screen.KEY_RIGHT,
                  ord('D'), ord('d')):
            game.tap()
        elif ev in (Screen.KEY_UP, ord('W'), ord('w')):
            game.restart()
        elif ev in (ord('P'), ord('p')):
            if game.is_paused():
                game.resume()
            else:
                game.pause()
        elif ev in (Screen.KEY_ESCAPE, ord('Q'), ord('q')):
            game.stop()
            break

        if args.color:
            renderer = ColourImageFile(screen,
                                       state.snapshot,
                                       height=args.height)
        else:
            renderer = ImageFile(state.snapshot,
                                 height=args.height,
                                 colours=screen.colours)

        image, colours = renderer.rendered_text
        for (i, line) in enumerate(image):
            screen.centre(line, i, colour_map=colours[i])
            # screen.paint(line, 0, i, colour_map=colours[i], transparent=False)
        screen.refresh()
Exemplo n.º 18
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()
Exemplo n.º 19
0
    def intro(self):
        scenes = []
        effects = [
            Mirage(self.screen,
                   FigletText("Mycroft TUI"),
                   self.screen.height // 2 - 3,
                   DEFAULT_COLOR,
                   start_frame=20,
                   stop_frame=150)
        ]
        scenes.append(Scene(effects, 200, name="Splash"))

        text = Figlet(font="banner", width=200).renderText("JARBASAI")
        width = max([len(x) for x in text.split("\n")])

        effects = [
            Print(self.screen,
                  ColourImageFile(self.screen,
                                  join(dirname(__file__), "logo.gif"),
                                  self.screen.height - 5,
                                  uni=self.screen.unicode_aware,
                                  dither=self.screen.unicode_aware),
                  y=1),
            Print(self.screen,
                  FigletText("JARBASAI", "banner"),
                  self.screen.height - 9,
                  x=(self.screen.width - width) // 2 + 1,
                  colour=Screen.COLOUR_BLACK,
                  bg=Screen.COLOUR_BLACK,
                  speed=1),
            Print(self.screen,
                  FigletText("JARBASAI", "banner"),
                  self.screen.height - 9,
                  colour=Screen.COLOUR_WHITE,
                  bg=Screen.COLOUR_WHITE,
                  speed=1),
        ]
        scenes.append(Scene(effects, duration=30, name="Jarbas"))
        return scenes
Exemplo n.º 20
0
        def internal_checks(screen):
            renderer = ColourImageFile(screen,
                                       os.path.join(os.path.dirname(__file__),
                                                    "globe.gif"),
                                       height=10)

            # Check renderer got all images from the file.
            count = 0
            for image in renderer.images:
                count += 1
                self.assertIsNotNone(image)
                self.assertIsNotNone(len(image) <= renderer.max_height)
            self.assertEqual(count, 11)

            # Check an image looks plausible
            image = next(renderer.images)
            self.assertEqual(image, [
                '', '        #####       ', '    #############   ',
                '  ################# ', ' ###################',
                '####################', '####################',
                ' ###################', ' ################## ',
                '   ###############  ', '     ###########    '
            ])
Exemplo n.º 21
0
def print_chat_area(screen):
    global cur_chat
    global chats_list
    tsize = shutil.get_terminal_size()
    x = 33
    width = tsize.columns - x - 1
    y = 1
    height = tsize.lines - 7
    msgs_list = chats_list[cur_chat][2]
    screen.clear_buffer(7, 1, 0, x, y, width, height)
    screen.refresh()
    t_y = y + height - 1
    for i in range(0, len(msgs_list)):
        s_from = ""
        if msgs_list[i].from_user is not None:
            s_from = msgs_list[i].from_user.first_name
        else:
            s_from = msgs_list[i].chat.title
        t_str = datetime.datetime.fromtimestamp(msgs_list[i].date).strftime(
            "%d.%m.%y %H:%M:%S") + " <" + s_from + ">: "
        if msgs_list[i].media:
            if msgs_list[i].audio:
                t_str += "[Audio]\n"
            if msgs_list[i].document:
                t_str += "[Document]\n"
            if msgs_list[i].photo:
                t_str += "[Photo]\n"
            if msgs_list[i].animation:
                t_str += "[Animation]\n"
            if msgs_list[i].sticker:
                t_str += "[Sticker]\n"
            if msgs_list[i].video:
                t_str += "[Video]\n"
            if msgs_list[i].voice:
                t_str += "[Voice]\n"
            if msgs_list[i].video_note:
                t_str += "[Video note]\n"
            if msgs_list[i].contact:
                t_str += "[Contact]\n"
            if msgs_list[i].location:
                t_str += "[Location]\n"
            if msgs_list[i].venue:
                t_str += "[Venue]\n"
            if msgs_list[i].caption:
                t_str += str(msgs_list[i].caption)
        else:
            t_str += str(msgs_list[i].text)
        t_lines = []
        while len(t_str) > width or t_str.find("\n") != -1:
            sn = t_str.find("\n", 0, width)
            if sn != -1:
                t_lines.append(t_str[:sn + 1])
                t_str = t_str[sn + 1:]
                continue
            if len(t_str) > width:
                t_lines.append(t_str[:width])
                t_str = t_str[width:]
                continue
        t_lines.append(t_str)
        for ii in range(len(t_lines) - 1, -1, -1):
            b_t_y = t_y
            try:
                if t_lines[ii].find("[Photo]") != -1:
                    with app:
                        tfile = app.download_media(msgs_list[i].photo)
                    ih = min(30, int(2 * height / 3))
                    renderer = ColourImageFile(screen, tfile, height=ih)
                    image, colours = renderer.rendered_text
                    t_y -= ih
                    for (j, line) in enumerate(image):
                        if t_y + j >= y:
                            screen.paint(line,
                                         x,
                                         t_y + j,
                                         colour_map=colours[j])
                if t_y < y:
                    return
            except:
                t_y = b_t_y
            screen.print_at(t_lines[ii], x, t_y, 7, 1, 0)
            t_y -= 1
            if t_y < y:
                return
Exemplo n.º 22
0
def demo(screen):
    scenes = []
    centre = (screen.width // 2, screen.height // 2)

    # Title
    effects = [
        BannerText(screen, ColourImageFile(screen, "pacman.png", 16, 0, True),
                   (screen.height - 16) // 2, Screen.COLOUR_WHITE),
        Print(
            screen,
            StaticRenderer(images=[
                "A tribute to the classic 80's "
                "video game by Namco."
            ]), screen.height - 1)
    ]
    #scenes.append(Scene(effects, 0))

    # Scene 1 - run away, eating dots
    path = Path()
    path.jump_to(screen.width + 16, centre[1])
    path.move_straight_to(-16, centre[1], (screen.width + 16) // 3)
    path.wait(100)

    if screen.colours <= 16:
        inky = 6
        pinky = 5
        blinky = 1
        clyde = 2
    else:
        inky = 14
        pinky = 201
        blinky = 9
        clyde = 208

    effects = [
        PacMan(screen, path),
        Ghost(screen, deepcopy(path), inky, start_frame=40),
        Ghost(screen, deepcopy(path), pinky, start_frame=60),
        Ghost(screen, deepcopy(path), blinky, start_frame=80),
        Ghost(screen, deepcopy(path), clyde, start_frame=100),
    ]

    for x in range(5, screen.width, 16):
        effects.insert(
            0,
            Print(screen,
                  StaticRenderer(images=[dot]),
                  screen.height // 2,
                  x=x,
                  speed=1,
                  stop_frame=4))

    scenes.append(Scene(effects, 100 + screen.width))

    # Scene 2 - Chase ghosts after a power pill
    scenes.append(EatingScene(screen))

    # Scene 3 - Thanks...
    effects = [
        Print(screen,
              FigletText("Thank you,"),
              screen.height // 3 - 3,
              colour=Screen.COLOUR_RED),
        Print(screen,
              StaticRenderer(images=[namco]),
              screen.height * 2 // 3 - 2,
              colour=Screen.COLOUR_RED),
        Print(screen, StaticRenderer(images=["< Press X to exit. >"]),
              screen.height - 1)
    ]
    scenes.append(Scene(effects, 0))

    screen.play(scenes, stop_on_resize=True, repeat=False)
Exemplo n.º 23
0
def demo(screen):

    scenes = []
    effects = [
        Print(screen,
              ColourImageFile(screen, "tenor.gif", screen.height - 2,
                              uni=screen.unicode_aware,
                              dither=screen.unicode_aware),
              0,
              stop_frame=200),
        Print(screen,
              FigletText("WASP",
                         font='epic' if screen.width > 80 else 'banner'),
              screen.height // 2 - 3,
              colour=7, bg=7 if screen.unicode_aware else 0),
        Print(screen,
              SpeechBubble("press <Space> to continue "),
              screen.height - 5,
              speed=1, transparent=False)
    ]
    scenes.append(Scene(effects))
    effects = [
        Print(screen, ImageFile("love.gif", screen.height - 2, colours=screen.colours),
              0,
              stop_frame=100),
    ]
    scenes.append(Scene(effects))

    effects = [
        Print(screen, ImageFile("sad_to_happy.gif", screen.height - 2, colours=screen.colours),
              0,
              stop_frame=100),
    ]
    scenes.append(Scene(effects))

    effects = [
        Print(screen, ImageFile("sad.jpg", screen.height - 2, colours=screen.colours),
              0,
              stop_frame=100),
    ]
    scenes.append(Scene(effects))

    effects = [
        Print(screen, ImageFile("neutral.jpg", screen.height - 2, colours=screen.colours),
              0,
              stop_frame=100),
    ]
    scenes.append(Scene(effects))

    effects = [
        Print(screen, ImageFile("smile.jpg", screen.height - 2, colours=screen.colours),
              0,
              stop_frame=100),
    ]
    scenes.append(Scene(effects))

    effects = [
        Print(screen, ImageFile("smiling.jpg", screen.height - 2, colours=screen.colours),
              0,
              stop_frame=100),
    ]
    scenes.append(Scene(effects))

    effects = [
        Print(screen, ImageFile("broken_heart.jpg", screen.height - 2, colours=screen.colours),
              0,
              stop_frame=100),
    ]
    scenes.append(Scene(effects))

    effects = [
        Print(screen, ImageFile("heart.jpg", screen.height - 2, colours=screen.colours),
              0,
              stop_frame=100),
    ]
    scenes.append(Scene(effects))

    effects = [
        Print(screen, ColourImageFile(screen, "poop.jpg", screen.height - 2,
                                      uni=screen.unicode_aware, dither=screen.unicode_aware),
              0,
              stop_frame=100),
        Print(screen,
              SpeechBubble("press <X> to exit "),
              screen.height - 5,
              speed=1, transparent=False)
    ]
    scenes.append(Scene(effects))

    screen.play(scenes, stop_on_resize=True)
Exemplo n.º 24
0
def demo(screen):
    #empty array to save all effects
    scenes = []
    #show text
    effects = [
        Print(screen,
              FigletText("yourname",
                         font='banner3' if screen.width > 80 else 'banner'),
              screen.height // 2 - 3,
              colour=7,
              bg=7 if screen.unicode_aware else 0),
    ]
    scenes.append(Scene(effects))
    #show taki.gif
    effects = [
        Print(screen,
              ColourImageFile(screen,
                              "assets/images/taki.gif",
                              screen.height,
                              uni=screen.unicode_aware),
              screen.height,
              speed=1),
        Scroll(screen, 2)
    ]
    scenes.append(Scene(effects))
    #show mitsuha.gif
    effects = [
        BannerText(
            screen,
            ColourImageFile(screen,
                            "assets/images/mitsuha.gif",
                            screen.height - 2,
                            uni=screen.unicode_aware,
                            dither=screen.unicode_aware), 0, 0),
    ]
    scenes.append(Scene(effects))
    #show mitshua2.gif
    effects = [
        Print(
            screen,
            ColourImageFile(screen,
                            "assets/images/mitsuha2.gif",
                            screen.height,
                            uni=screen.unicode_aware),
            screen.height,
            speed=1,
        ),
        Scroll(screen, 2)
    ]
    scenes.append(Scene(effects))
    #show both.gif
    effects = [
        Print(screen,
              ColourImageFile(screen,
                              "assets/images/both.gif",
                              screen.height - 2,
                              uni=screen.unicode_aware,
                              dither=screen.unicode_aware),
              0,
              stop_frame=200),
    ]
    scenes.append(Scene(effects))
    #show end text
    effects = [
        Cycle(screen, FigletText("KimiNoNamaewa?", font="big"),
              int(screen.height / 2 - 8)),
        Cycle(
            screen,
            FigletText("YourName", font="small"),
            int(screen.height / 2 + 3),
        ),
    ]
    scenes.append(Scene(effects))
    screen.play(scenes, stop_on_resize=True)
Exemplo n.º 25
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)
Exemplo n.º 26
0
def demo(screen):
    path = os.path.abspath(__file__)
    assetpath = os.path.dirname(path)
    scenes = []
    #Apt-get install...
    effects = [
        Cycle(screen, FigletText("apt-get install", font='big'),
              int(screen.height // 2 - 8)),
    ]
    scenes.append(Scene(effects, 60))

    #Docker
    effects = [
        Cycle(
            screen,
            ColourImageFile(screen, assetpath + "/assets/docker-logo.png", 16,
                            0, False), int(screen.height // 2 - 12)),
        Cycle(screen, FigletText("DOCKER", font='big'),
              int(screen.height // 2 + 3))
    ]
    scenes.append(Scene(effects, 60))

    effects = [
        Cycle(
            screen,
            ColourImageFile(screen, assetpath + "/assets/nodejs-logo.png", 16,
                            0, False), int(screen.height // 2 - 14)),
        Cycle(screen, FigletText("NODE.JS", font='big'),
              int(screen.height // 2 + 3))
    ]
    scenes.append(Scene(effects, 60))

    effects = [
        Cycle(
            screen,
            ColourImageFile(screen, assetpath + "/assets/git_logo.png", 16, 0,
                            False), int(screen.height // 2 - 14)),
        Cycle(screen, FigletText("GIT", font='big'),
              int(screen.height // 2 + 3))
    ]
    scenes.append(Scene(effects, 60))

    # system76
    effects = [
        Cycle(
            screen,
            ColourImageFile(screen,
                            assetpath + "/assets/system76_logo_white.png", 16,
                            0, False), int(screen.height // 2 - 14)),
        Cycle(screen, FigletText("Laptops for Developers", font='big'),
              int(screen.height // 2 + 3)),
        Stars(screen, (screen.width + screen.height) // 2),
        Print(screen,
              SpeechBubble("Press \"X\" to learn more!"),
              screen.height - 3,
              speed=1,
              transparent=False,
              start_frame=20)
    ]
    scenes.append(Scene(effects))
    screen.play(scenes, stop_on_resize=True)
Exemplo n.º 27
0
def layout(screen):

    global data, CURRENT

    def reloadData():

        global data, CURRENT

        while True:

            time.sleep(1)

            ccategory = CURRENT.get("category")

            if (ccategory in data and data[ccategory] is not None
                    and data[ccategory].get("created_at")
                    and int(data[ccategory].get("created_at")) +
                    CONFIG["refresh"] < int(time.time())
                    and not CONFIG.get("loading")):

                CONFIG["loading"] = True

                alert(screen, "UPDATING")

                if ccategory == "twitter":
                    try:
                        d = getTwitter(page=1)
                    except Exception as e:
                        CONFIG["loading"] = False
                        alert(screen, str(e))
                        time.sleep(0.5)
                        if ccategory not in data:
                            data[ccategory] = {}
                        data[ccategory]["created_at"] = int(time.time())
                        return
                else:
                    d = getFeedFromRSS(CURRENT["category"])

                    if not d:
                        CONFIG["loading"] = False
                        alert(
                            screen, "Api limit exceeded"
                            if ccategory == "twitter" else "Update failed")
                        time.sleep(0.5)
                        if ccategory not in data:
                            data[ccategory] = {}
                        data[ccategory]["created_at"] = int(time.time())
                        return

                CONFIG["loading"] = False

                data[ccategory] = d

                if ccategory != CURRENT["category"]:
                    return

                if CURRENT["line"][CURRENT["category"]] > -1:
                    i = -1
                    for entry in data[ccategory]["entries"]:
                        i += 1
                        if entry["id"] == CURRENT["id"]:
                            CURRENT["line"][CURRENT["category"]] = i
                            break
                    CURRENT["line"][CURRENT["category"]] = i

                drawCategories()
                drawEntries(force=True)
                screen.refresh()

    def isDoubleChar(s):

        return (re.compile(
            "(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff]|[가-힣]|[\u4e00-\u9fff]|[\u3400-\u4dbf]|[\U00020000-\U0002a6df]|[\U0002a700-\U0002b73f]|[\U0002b740-\U0002b81f]|[\U0002b820-\U0002ceaf])"
        ).findall(s) != [])

    def textLength(s):

        return sum([2 if isDoubleChar(d) else 1 for d in s])

    def alert(screen, text):

        space = 3
        length = textLength(text) + space * 2
        text = " " * space + text + " " * space
        pos = (screen.width - len(text), 0)

        screen.print_at(text,
                        pos[0],
                        pos[1],
                        colour=COLOR["alertfg"],
                        bg=COLOR["alertbg"])
        screen.refresh()

    def sliceText(s, l, maxwidth=80, shift=0):
        rslt = ""

        stringLength = textLength(s)

        over = stringLength > maxwidth

        if over:  # to show a marquee
            if stringLength - shift + CONFIG[
                    "marqueeDelayReturn"] < maxwidth or shift == -1:
                if CURRENT.get("direction", "left") == "left":
                    CURRENT["direction"] = "right"
                else:
                    CURRENT["direction"] = "left"

            if CURRENT.get("direction", "left") == "left":
                if shift < CONFIG["marqueeDelay"]:
                    shift = 0
                else:
                    shift -= CONFIG["marqueeDelay"]

            if stringLength - shift + maxwidth / 4 < maxwidth:
                shift = stringLength - maxwidth + maxwidth / 4

        m = 0
        for d in s:
            m += 1
            if isDoubleChar(d):
                m += 1
            if not over:
                rslt += d
            else:
                if m == shift and isDoubleChar(d):
                    rslt += " "
                elif m >= shift:
                    rslt += d

            if m >= l + shift or m >= maxwidth + shift:
                break

        return rslt

    def drawCategories():

        screen.print_at("." * screen.width,
                        0,
                        0,
                        colour=COLOR["categorybg"],
                        bg=COLOR["categorybg"])

        x = 1
        for category in CONFIG["categories"]:
            s = " %s " % category[1]
            if category[0] == CURRENT["category"]:
                screen.print_at(s,
                                x,
                                0,
                                colour=COLOR["categoryfgS"],
                                bg=COLOR["categorybgS"])
            else:
                screen.print_at(s,
                                x,
                                0,
                                colour=COLOR["categoryfg"],
                                bg=COLOR["categorybg"])

            x += len(s) + 2

    def drawEntries(clearline=False, force=False, lines=False):

        category_ = CURRENT["category"]
        if category_ not in FIELDS:
            category_ = "default"

        if data[CURRENT["category"]] is None:
            return

        lineRange = range(0, CONFIG["rowlimit"])

        if lines:
            lineRange = range(0, lines)

        elif CURRENT["line"][CURRENT["category"]] > -1 and not force:
            lineRange = [CURRENT["line"][CURRENT["category"]]]
            if CURRENT["oline"] != CURRENT["line"][
                    CURRENT["category"]] and CURRENT["oline"] != -1:
                lineRange = [
                    CURRENT["oline"], CURRENT["line"][CURRENT["category"]]
                ]

        for i in lineRange:
            isSelected = (i == CURRENT["line"][CURRENT["category"]]
                          ) and not CURRENT.get("input", False)
            row = i + 1
            index = i + CURRENT["page"][CURRENT["category"]] * (screen.height -
                                                                2)

            if isSelected:
                screen.print_at(" " * screen.width,
                                0,
                                row,
                                colour=COLOR["selected"],
                                bg=COLOR["selected"])
            else:
                screen.print_at(" " * screen.width, 0, row, colour=0, bg=0)

            if CURRENT["line"][CURRENT[
                    "category"]] > -1 and clearline and not force and not isSelected:
                screen.refresh()

            for f in FIELDS[category_]:
                kColor = 2 if len(f) > 2 else 1

                txt = data[CURRENT["category"]]["entries"][index].get(f[1], "")

                if isSelected and f[1] + "S" in data[
                        CURRENT["category"]]["entries"][index]:
                    txt = data[CURRENT["category"]]["entries"][index][f[1] +
                                                                      "S"]
                    if f[1] in data[
                            CURRENT["category"]]["entries"][index] and len(
                                data[CURRENT["category"]]["entries"][index][
                                    f[1]]) > len(txt):

                        txt += " " * (len(data[CURRENT["category"]]["entries"]
                                          [index][f[1]]) - len(txt))

                if txt == "":
                    continue

                col = f[0]

                if col < 0:
                    col = screen.width + col - len(txt)
                elif CURRENT.get("input", False):
                    col += 4

                fg = COLOR.get(f[kColor], COLOR["default"])
                bg = 0

                if i == CURRENT["line"][
                        CURRENT["category"]] and not CURRENT.get(
                            "input", False):
                    fg = 0
                    bg = COLOR["selected"]
                    if COLOR.get("%sS" % f[kColor], None):
                        fg = COLOR["%sS" % f[kColor]]

                if isSelected and f[1] in CONFIG["marqueeFields"]:
                    txt = sliceText(txt,
                                    screen.width - col - 1,
                                    maxwidth=screen.width - col,
                                    shift=CURRENT["shift"])

                if col > 1:
                    col -= 1
                    txt = " %s " % txt

                if len(f) > 3:
                    txt += " " * 20

                try:
                    screen.print_at(txt, col, row, colour=fg, bg=bg)
                except:
                    pass

            if CURRENT["line"][CURRENT[
                    "category"]] > -1 and clearline and not force and not isSelected:
                screen.refresh()

        if force and lineRange[-1] + 1 < screen.height - 1:
            for i in range(lineRange[-1] + 2, screen.height):
                screen.print_at(" " * screen.width, 0, i, colour=0, bg=0)

            screen.refresh()

    def pageUp():
        if CURRENT["page"][CURRENT["category"]] == 0:
            CURRENT["line"][CURRENT["category"]] = 0
            alert(screen, "top of the list")
            time.sleep(0.5)
            drawCategories()
        else:
            CURRENT["line"][CURRENT["category"]] = CONFIG["rowlimit"] - 1
            CURRENT["page"][CURRENT["category"]] -= 1
            CONFIG["rowlimit"] = screen.height - 2

    def pageDown():
        if len(data[CURRENT["category"]]
               ["entries"]) - (CURRENT["page"][CURRENT["category"]] +
                               1) * (screen.height - 2) < CONFIG["rowlimit"]:
            CURRENT["line"][CURRENT["category"]] = CONFIG["rowlimit"] - 1
            alert(screen, "end of the list")
            time.sleep(0.5)
            drawCategories()
        else:
            CURRENT["line"][CURRENT["category"]] = 0
            CURRENT["page"][CURRENT["category"]] += 1
            CONFIG["rowlimit"] = screen.height - 2

    def doTimer():
        if CURRENT["line"][CURRENT["category"]] > -1:
            CURRENT["shift"] = CURRENT.get("shift", 0) + (1 if CURRENT.get(
                "direction", "left") == "left" else -1)
            drawEntries()
            screen.refresh()

    def resetListArrowKey():
        CURRENT["shift"] = 0
        CURRENT["oline"] = CURRENT["line"][CURRENT["category"]]

    def showCurrentInputNumber():

        lineRange = range(0, CONFIG["rowlimit"])

        try:
            currentNumber = int(CURRENT["inputnumber"])
        except:
            currentNumber = ""

        for i in lineRange:
            fg = COLOR["number"]
            if i + 1 == currentNumber:
                fg = COLOR["numberselected"]
            screen.print_at(("%3s" % (i + 1)).rjust(3),
                            1,
                            i + 1,
                            colour=fg,
                            bg=0)

        screen.refresh()

    def offNumberMode():
        CURRENT["shift"] = 0
        CURRENT["input"] = False
        CURRENT["inputnumber"] = ""

        drawEntries(clearline=True, force=True)
        screen.refresh()

    def openURL(cn):

        if "link" in cn:
            webbrowser.open(cn["link"], new=2)
        elif "url" in cn:
            webbrowser.open(cn["url"], new=2)
        elif "links" in cn:
            if len(cn["links"]) == 1:
                webbrowser.open(cn["links"][0], new=2)
            else:
                webbrowser.open(cn["permalink"], new=2)
        elif "permalink" in cn:
            webbrowser.open(cn["permalink"], new=2)
        else:
            return False

        return True

    def showHelp():
        w = 60
        s = """
            [Up], [Down], [W], [S], [J], [K] : Select from list
[Shift]+[Up], [Shift]+[Down], [PgUp], [PgDn] : Quickly select from list
                                     [Space] : Open attached image or URL
                                         [O] : Open canonical link
                                         [:] : Select by typing a number from list
                        [Tab], [Shift]+[Tab] : Change the category tab
                             [Q], [Ctrl]+[C] : Quit
"""

        s = s.split("\n")
        lines = len(s)
        width = max([len(d) for d in s]) + 2

        screen.clear()
        top = int(screen.height / 2 - lines / 2)
        left = int(screen.width / 2 - width / 2)
        for i, d in enumerate(s):
            screen.print_at(" " * width,
                            left - 1,
                            top + i,
                            colour=COLOR["alertfg"],
                            bg=COLOR["alertbg"])
            screen.print_at(d,
                            left,
                            top + i,
                            colour=COLOR["alertfg"],
                            bg=COLOR["alertbg"])

        screen.refresh()
        idx = 0
        while True:
            if screen.get_key():
                return
            time.sleep(0.5)

        screen.clear()

    reloadLoop = threading.Thread(target=reloadData, args=[])
    reloadLoop.daemon = True
    reloadLoop.start()

    CURRENT = {
        "line": {category[0]: -1
                 for category in CONFIG["categories"]},
        "column": -1,
        "category": "twitter",
        "page": {category[0]: 0
                 for category in CONFIG["categories"]}
    }

    data[CURRENT["category"]] = getData(CURRENT["category"])

    CONFIG["rowlimit"] = screen.height - 2
    if data.get(CURRENT["category"]) is not None and len(
            data[CURRENT["category"]].get("entries", [])) < CONFIG["rowlimit"]:
        CONFIG["rowlimit"] = len(data[CURRENT["category"]]["entries"])

    if CONFIG["rowlimit"] > 999:
        CONFIG["rowlimit"] = 999

    screen.clear()
    drawCategories()
    drawEntries(force=True)
    screen.refresh()

    currentTime = int(time.time() * CONFIG["marqueeSpeed"])

    while True:

        time.sleep(0.02)

        keyCode = screen.get_key()

        if keyCode:

            if keyCode == KEY["esc"] or keyCode in KEY["q"]:
                screen.clear()
                screen.refresh()
                return True

            elif CURRENT.get("input"):
                if keyCode == KEY["enter"] or keyCode == KEY[":"]:

                    if keyCode == KEY[
                            "enter"] and CURRENT["inputnumber"] != "" and int(
                                CURRENT["inputnumber"]) <= CONFIG["rowlimit"]:
                        CURRENT["line"][CURRENT["category"]] = int(
                            CURRENT["inputnumber"]) - 1
                    else:
                        CURRENT["line"][CURRENT["category"]] = CURRENT["oline"]

                    offNumberMode()
                    continue

                elif keyCode in KEYLIST["number"]:
                    if len(CURRENT["inputnumber"]) < 3:
                        CURRENT["inputnumber"] += str(keyCode -
                                                      KEYLIST["number"][0])

                elif keyCode == KEY["backspace"]:
                    if CURRENT["inputnumber"] != "":
                        CURRENT["inputnumber"] = CURRENT["inputnumber"][:-1]
                    else:
                        CURRENT["line"][CURRENT["category"]] = CURRENT["oline"]
                        offNumberMode()
                        continue

                showCurrentInputNumber()

                continue

            elif keyCode in KEY["r"]:
                CURRENT["line"][CURRENT["category"]] = -1
                data[CURRENT["category"]] = getData(CURRENT["category"])
                CONFIG["rowlimit"] = screen.height - 2
                if len(data[CURRENT["category"]]
                       ["entries"]) < CONFIG["rowlimit"]:
                    CONFIG["rowlimit"] = len(
                        data[CURRENT["category"]]["entries"])
                drawEntries()
                screen.refresh()

            elif keyCode == KEY["esc"]:
                resetListArrowKey()
                CURRENT["line"][CURRENT["category"]] = -1

            elif keyCode == KEY["down"] or keyCode in KEY["j"] + KEY["s"]:
                resetListArrowKey()
                CURRENT["line"][CURRENT["category"]] += 1
                if CURRENT["line"][CURRENT["category"]] >= CONFIG["rowlimit"]:
                    pageDown()
                    drawEntries(force=True)
                    screen.refresh()

            elif keyCode == KEY["up"] or keyCode in KEY["k"] + KEY["w"]:
                resetListArrowKey()
                CURRENT["line"][CURRENT["category"]] -= 1
                if CURRENT["line"][CURRENT["category"]] < 0:
                    pageUp()
                    drawEntries(force=True)
                    screen.refresh()

            elif keyCode == KEY["shiftUp"]:
                resetListArrowKey()
                CURRENT["line"][CURRENT["category"]] -= 10
                if CURRENT["line"][CURRENT["category"]] < 0:
                    pageUp()
                    drawEntries(force=True)
                    screen.refresh()

            elif keyCode == KEY["shiftDown"]:
                CURRENT["shift"] = 0
                CURRENT["oline"] = CURRENT["line"][CURRENT["category"]]
                CURRENT["line"][CURRENT["category"]] += 10
                if CURRENT["line"][CURRENT["category"]] >= CONFIG["rowlimit"]:
                    pageDown()
                    drawEntries(force=True)
                    screen.refresh()

            elif keyCode in KEY["o"]:
                openURL(data[CURRENT["category"]]["entries"]
                        [CURRENT["line"][CURRENT["category"]] +
                         CURRENT["page"][CURRENT["category"]] *
                         (screen.height - 2)])

            elif keyCode == KEY["space"]:
                cn = data[CURRENT["category"]]["entries"][
                    CURRENT["line"][CURRENT["category"]] +
                    CURRENT["page"][CURRENT["category"]] * (screen.height - 2)]

                if "medias" in cn and not CURRENT.get("media", False):
                    for url in cn["medias"]:
                        urllib.request.urlretrieve(url, ".rterm_tmp.jpg")

                        effect = Print(screen,
                                       ColourImageFile(screen,
                                                       ".rterm_tmp.jpg",
                                                       height=screen.height,
                                                       bg=0,
                                                       fill_background=0,
                                                       dither=False,
                                                       uni=True),
                                       y=0)

                        screen.play([Scene([effect])],
                                    stop_on_resize=True,
                                    repeat=False)
                        os.remove(".rterm_tmp.jpg")

                        screen.clear()
                    drawCategories()
                    drawEntries(force=True)
                    screen.refresh()
                else:
                    openURL(cn)

            elif keyCode == KEY[":"]:
                CURRENT["input"] = True
                CURRENT["oline"] = CURRENT["line"][CURRENT["category"]]
                CURRENT["line"][CURRENT["category"]] = -1
                CURRENT["inputnumber"] = ""

                drawEntries(clearline=True, force=True)
                showCurrentInputNumber()
                screen.refresh()

            elif keyCode in KEY["h"] or keyCode == KEY["?"]:
                showHelp()
                drawCategories()
                drawEntries(clearline=True, force=True)
                screen.refresh()

            elif keyCode in [KEY["tab"], KEY["shiftTab"]]:
                for idx, d in enumerate(CONFIG["categories"]):
                    if CURRENT["category"] == d[0]:
                        try:
                            CURRENT["category"] = CONFIG["categories"][
                                idx + (1 if keyCode == KEY["tab"] else -1)][0]
                        except:
                            CURRENT["category"] = CONFIG["categories"][
                                0 if keyCode == KEY["tab"] else -1][0]
                        break

                drawCategories()
                alert(screen, "LOADING")

                data[CURRENT["category"]] = getData(CURRENT["category"])

                CONFIG["rowlimit"] = screen.height - 2
                if data[CURRENT["category"]] is not None and len(data[
                        CURRENT["category"]]["entries"]) < CONFIG["rowlimit"]:
                    CONFIG["rowlimit"] = len(
                        data[CURRENT["category"]]["entries"])

                drawCategories()
                drawEntries(force=True)
                screen.refresh()

            if CURRENT["line"][CURRENT["category"]] > -1:
                CURRENT["id"] = data[CURRENT["category"]]["entries"][
                    CURRENT["line"][CURRENT["category"]]].get("id", "")

            if keyCode in KEYLIST["arrow"]:
                drawEntries(clearline=True)
                screen.refresh()
            """  
            # for keyCode debug
            screen.print_at('%s   ' % keyCode, screen.width - 15, screen.height - 2, colour=0, bg=15)
            screen.refresh()
            #"""

        if CURRENT["line"][CURRENT["category"]] > -1:
            oCurrentTime = currentTime
            currentTime = int(
                time.time() *
                (CONFIG["marqueeSpeed" if CURRENT.get("direction", "left") ==
                        "left" else "marqueeSpeedReturn"]))

            if oCurrentTime != currentTime:
                doTimer()

        if screen.has_resized():
            return False