terminal.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:connect4 作者: guglielmilo 项目源码 文件源码
def addString(y, x, string, string_color=color.BLACK, bold=False):
    if x == position.CENTER:
        x = width/2 - len(string)/2
    options = 0
    if curses.can_change_color():
        # tokens special cases color
        if string == 'X':
            options = curses.color_pair(color.RED) if not bold else curses.color_pair(color.RED_H) | curses.A_BOLD
        elif string == 'O':
            options = curses.color_pair(color.YELLOW) if not bold else curses.color_pair(color.YELLOW_H) | curses.A_BOLD
        else:
            options = curses.color_pair(string_color)
    if bold:
        options |= curses.A_BOLD
    stdscr.addstr(y, x, string, options)
    stdscr.refresh()

# main display
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号