Example #1
0
 async def draw_live(self):
     remaining = 0
     while True:
         if remaining == 0:
             remaining = self.settings.refresh
             await self.draw()
             self._draw_buffer += 3
         else:
             erase_lines(3)
             remaining -= 1
         style_print(f"\nrefreshing in {remaining}", style="cyan")
         style_print("press CTRL-C to quit", style="cyan")
         await asyncio.sleep(1)
Example #2
0
 async def draw_live(self):
     remaining = 0
     try:
         while True:
             if remaining == 0:
                 remaining = self.settings.refresh
                 await self.draw()
                 self._draw_buffer += 3
             else:
                 erase_lines(3)
                 remaining -= 1
             style_print(f"\nrefreshing in {remaining}", style="cyan")
             style_print("press CTRL-C to quit", style="cyan")
             sleep(1)
     except KeyboardInterrupt:
         pass
Example #3
0
    async def draw(self):
        lines = []
        await self.stock_store.update()
        if self.settings.watchlist:
            lines += self.watchlist

        if self.settings.positions:
            lines.append("")
            lines += self.positions
            lines.append("")
            lines += self.profit_and_loss
            lines.append("")
            lines += self.balances_str
        if self._draw_buffer:
            erase_lines(self._draw_buffer)
        self._draw_buffer = len(lines)
        print("\n".join(lines))
Example #4
0
    def update(self, step, steps):
        """ Manually updates the progress bar
        """
        try:
            # Python 3.3+ only
            width = self.width or os.get_terminal_size().columns
        except (AttributeError, OSError):
            width = 80

        prefix = "%s: " % self.label
        format_specifier = "%%0%dd" % len(str(steps))
        prefix += "%s/%d%s" % (
            format_specifier % step,
            steps,
            self.chars["left-edge"],
        )
        suffix = self.chars["right-edge"] + "%03d%%" % (step / steps * 100)
        units_total = max(width - len(io.strip_format(prefix + suffix)), 5)
        units = units_total * step // steps
        line = (prefix + units * self.chars["block"] +
                (units_total - units) * " " + suffix)
        io.erase_lines()
        print("\r%s" % line)
Example #5
0
def demo_io_erase_lines():
    print("press [ENTER] to erase line")
    input("/" * 80)
    io.erase_lines()