当前位置: 首页>>代码示例>>Python>>正文


Python Terminal.bold方法代码示例

本文整理汇总了Python中blessed.Terminal.bold方法的典型用法代码示例。如果您正苦于以下问题:Python Terminal.bold方法的具体用法?Python Terminal.bold怎么用?Python Terminal.bold使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在blessed.Terminal的用法示例。


在下文中一共展示了Terminal.bold方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: console

# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import bold [as 别名]
def console():
    t = Terminal()

    # clear screen
    print(t.clear, end="")

    # retrieve vended display object
    try:
        calculon.disp = Pyro4.Proxy(ENV.main_dir.uri.content)
    except:
        print(t.bold("Failed to connect to display"))
        calculon.disp = None
    repl.disp = calculon.disp

    # connect to voltron
    try:
        calculon.V = VoltronProxy()
        calculon.V.disp = calculon.disp
        calculon.V.update_disp()
    except NameError:
        pass

    # run repl
    code.InteractiveConsole.runsource = repl.CalculonInterpreter().runsource
    code.interact(local=locals())

    # clean up
    if calculon.V:
        calculon.V._disconnect()
    if calculon.disp:
        calculon.disp._pyroRelease()
开发者ID:l1kw1d,项目名称:calculon,代码行数:33,代码来源:main.py

示例2: speed_read

# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import bold [as 别名]
def speed_read(words, speed):
    term = Terminal()
    call(['clear'])
    with term.fullscreen():
        for w in words:
            printable = w.decode('utf-8')
            print(term.move_y(term.height // 2) + term.center(term.bold(printable)).rstrip())
            time.sleep(speed)
            call(["clear"])
开发者ID:encima,项目名称:scli,代码行数:11,代码来源:scli.py

示例3: day

# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import bold [as 别名]
def day(args, *extra, **kwargs):
    parser = argparse.ArgumentParser()
    parser.add_argument(
        'username',
        help='The MyFitnessPal username for which to delete a stored password.'
    )
    parser.add_argument(
        'date',
        nargs='?',
        default=datetime.now().strftime('%Y-%m-%d'),
        type=lambda datestr: dateparse(datestr).date(),
        help='The date for which to display information.'
    )
    args = parser.parse_args(extra)

    password = get_password_from_keyring_or_interactive(args.username)
    client = Client(args.username, password)
    day = client.get_date(args.date)

    t = Terminal()

    print(t.blue(args.date.strftime('%Y-%m-%d')))
    for meal in day.meals:
        print(t.bold(meal.name.title()))
        for entry in meal.entries:
            print('* {entry.name}'.format(entry=entry))
            print(
                t.italic_bright_black(
                    '  {entry.nutrition_information}'.format(entry=entry)
                )
            )
        print('')

    print(t.bold("Totals"))
    for key, value in day.totals.items():
        print(
            '{key}: {value}'.format(
                key=key.title(),
                value=value,
            )
        )
    print("Water: {amount}".format(amount=day.water))
    if day.notes:
        print(t.italic(day.notes))
开发者ID:norges,项目名称:python-myfitnesspal,代码行数:46,代码来源:commands.py

示例4: D

# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import bold [as 别名]
		shares_marker = ""

		hashrate_change = ""
		hashrate_diff = ""
		hashrate_marker = ""

		shares_A = D(metrics_A["shares"])
		shares_B = D(metrics_B["shares"])
		
		hashrate_A = D(metrics_A["hashrate"])
		hashrate_B = D(metrics_B["hashrate"])
		
		if(shares_A < shares_B):
			shares_change = "UP"
			shares_diff = shares_B - shares_A
			shares_marker = t.bold(t.green('UP')) 
		
		if(shares_B < shares_A):
			shares_change = "DOWN"
			shares_diff = abs(shares_A - shares_B)
			shares_marker = t.bold(t.red('DOWN'))

		if(hashrate_A < hashrate_B):
			hashrate_change = "UP"
			hashrate_diff = hashrate_B - hashrate_A
			hashrate_marker = t.bold(t.green('UP'))

		if(hashrate_A > hashrate_B):
			hashrate_change = "DOWN"
			hashrate_diff = abs(hashrate_A - hashrate_B)
			hashrate_marker = t.bold(t.red('DOWN'))			
开发者ID:ArcAster,项目名称:EtherPool-Stats,代码行数:33,代码来源:logger.py

示例5: main

# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import bold [as 别名]
def main(argv=None):
    """ Execute the application CLI.

    Arguments are taken from sys.argv by default.

    """

    args = _cmdline(argv)
    logger.start(args.logging_level)
    logger.debug("starting execution")

    #  get repo and initialize GitHeat instance
    try:
        g = Git(os.getcwd())
    except (InvalidGitRepositoryError, GitCommandError, GitCommandNotFound):
        print("Are you sure you're in an initialized git directory?")
        return 0
    githeat = Githeat(g, **vars(args))
    githeat.parse_commits()
    githeat.init_daily_contribution_map()
    githeat.compute_daily_contribution_map()
    githeat.normalize_daily_contribution_map()
    matrix = githeat.compute_graph_matrix()

    term = Terminal()
    matrix_width = githeat.get_matrix_width(matrix)
    if matrix_width > term.width:
        print("Your terminal width is smaller than the heatmap. Please consider using "
              "the --width {thin, reg, thick} argument, resizing your terminal, or "
              "merging months by including --month-merge.")
        return 0
    new_width = (term.width - matrix_width) // 2
    csr = Cursor(term.height // 2 - 3, new_width, term)

    screen = {}
    screen_dates = {}
    with term.hidden_cursor(), \
         term.raw(), \
         term.location(), \
         term.fullscreen(), \
         term.keypad():

        # Print header
        print_header_left(term, unicode(os.getcwd()), screen)
        text = u'GitHeat {}'.format(__version__)
        print_header_center(term, text, screen)
        text = u'ESC, ^c to exit'
        print_header_right(term, text, screen)

        # Print footer
        text = u'Please move cursor to navigate through map'
        print_footer_left(term, term.bold(text), screen)

        graph_right_most_x = term.width  # initialized at terminal width
        graph_left_most_x = csr.x
        graph_top_most_y = csr.y
        graph_x, graph_y = csr.x, csr.y

        #  get graph boundaries
        for i in range(7):
            #  for the week column in the matrix
            for week in matrix:
                if githeat.month_merge:
                    #  check if value in that week is just empty spaces and not colorize
                    if week.col[i][1] == githeat.width:
                        continue
                graph_x += len(githeat.width)

            graph_right_most_x = graph_x
            graph_x = graph_left_most_x  # reset x
            graph_y += 1
        graph_bottom_most_y = graph_y - 1

        #  print graph
        graph_x, graph_y = csr.x, csr.y
        print_graph(term, screen, screen_dates, graph_x, graph_y,
                    graph_left_most_x, matrix, githeat)

        # print legend
        block_separation_width = 4
        legend_x = (term.width - len(githeat.colors) * block_separation_width) // 2
        legend_y = graph_bottom_most_y + 5
        if not githeat.hide_legend:
            print_graph_legend(legend_x, legend_y,
                               githeat.width,
                               block_separation_width,
                               githeat.colors,
                               screen,
                               term)

        while True:
            cursor_color = colorize(githeat.width, ansi=15, ansi_bg=15)
            echo_yx(csr, cursor_color)
            inp = term.inkey()

            if inp in QUIT_KEYS:
                # Esc or ^c pressed
                break
            elif inp == chr(99):
                # c pressed, thus change color
#.........这里部分代码省略.........
开发者ID:AmmsA,项目名称:Githeat,代码行数:103,代码来源:interactive.py

示例6: open_commits_terminal

# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import bold [as 别名]
def open_commits_terminal(new_cursor_date_value, commits_on_date, githeat):
    """
    Creates a new terminal window for showing commits info
    :param new_cursor_date_value:
    :param commits_on_date:
    :param githeat: Githeat instance
    :return:
    """
    screen = {}
    term = Terminal()
    with term.keypad():
        redraw(term=term, screen={})

        # Print header
        print_header_left(term, str(new_cursor_date_value), screen)
        text = u'GitHeat {}'.format(__version__)
        print_header_center(term, text, screen)
        text = u'ESC, to return'
        print_header_right(term, text, screen)
        #  hold the commit info that we will display depending on scrolling window edges
        commit_values_holder = []
        for commit in commits_on_date:
            commit_hash, cdate, spaces, subject, author, email, = resize_until_fit(
                    [
                        commit.abbr_commit_hash,
                        str(commit.date.strftime("%H:%M:%S %z")),
                        "  ",
                        commit.subject,
                        commit.author,
                        commit.author_email,
                    ],
                    term.width - 7  # for spaces and '<', '>' between emails
            )

            value = [
                colorize(commit_hash, ansi=githeat.colors[1]),
                cdate,
                spaces,
                term.bold(subject),
                colorize(author, ansi=githeat.colors[2]),
            ]

            if email:
                value.append(colorize("<{}>".format(email), ansi=githeat.colors[3]))

            value = " ".join(value)
            commit_values_holder.append(value)

        starting_y = 2
        x = 0
        range_from = 0
        range_to = term.height - starting_y
        for value in commit_values_holder[range_from:range_to]:
            location = Cursor(starting_y, x, term)
            echo_yx(location, value)
            starting_y += 1

        while True:
            inp = term.inkey()

            if inp in chr(27):  # ESC to return
                break
            elif inp == chr(3):  # ^c to exit
                sys.exit(0)

            # scrolling window on commits
            starting_y = 2  # to not override header text
            if inp.code == term.KEY_UP:
                if range_from == 0:
                    continue
                range_from -= 1
            elif inp.code == term.KEY_DOWN:
                #  skip scrolling if commits fit terminal height
                if len(commit_values_holder[range_from:]) < term.height:
                    continue
                range_from += 1

            redraw(term=term, screen=screen)
            #  echo the commits based on scrolling window
            for value in commit_values_holder[range_from:]:
                if starting_y > term.height:
                    break
                location = Cursor(starting_y, x, term)
                echo_yx(location, value)
                starting_y += 1
开发者ID:AmmsA,项目名称:Githeat,代码行数:87,代码来源:interactive.py


注:本文中的blessed.Terminal.bold方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。