Python curses 模块,A_DIM 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用curses.A_DIM

项目:defuse_division    作者:lelandbatey    | 项目源码 | 文件源码
def refresh(self):
        prior, (cursr_y, cursr_x) = curses.curs_set(0), curses.getsyx()
        for idx, item in enumerate(self.items):
            fmt = '{{: <{}}}'.format(self.width-1)
            s = fmt.format(str(item))[:self.width-1]
            # s = str(item)[:self.width-1] if len(str(item)) > self.width-1 else str(item)
            color = colors.get_colorpair(self.default_color)
            if self.current == idx:
                if self.is_selected:
                    color = colors.get_colorpair('black-white')
                else:
                    color = colors.get_colorpair(self.highlight_color)
            self.textinpt.addstr(idx, 0, s, color)
        if self.is_selected:
            self.borderbox.bkgd(' ', curses.A_BOLD)
        else:
            self.borderbox.bkgd(' ', curses.A_DIM)
        self.borderbox.border()
        self.borderbox.refresh()
        self.textinpt.refresh()

        curses.curs_set(prior)
        curses.setsyx(cursr_y, cursr_x)
        curses.doupdate()
项目:Minesweeper    作者:M-Mueller    | 项目源码 | 文件源码
def draw_game(stdscr, rect, game):
    """Draws the game fields."""
    rect = Rect(rect.x, rect.y, game.column_count()*2+1, game.row_count()+2)
    rect = draw_frame(stdscr, rect)

    for i, (mine, flag, hint) in enumerate(zip(game.mines, game.flags, game.hints)):
        x, y = game.mines.linear_to_subscript(i)
        x = x*2 + rect.x # add padding between characters to get a nicer aspect ratio
        y = y + rect.y
        if flag == minesweeper.Flags.Unknown:
            stdscr.addstr(y, x, "?")
        elif flag == minesweeper.Flags.Marked:
            stdscr.addstr(y, x, "\u26F3") # flag in hole
        else:
            if mine:
                stdscr.addstr(y, x, "\u26ED") # gear without hub
            else:
                if hint == 0:
                    stdscr.addstr(y, x, " ")
                else:
                    stdscr.addstr(y, x, str(hint), curses.A_DIM)
    return rect
项目:botany    作者:jifunks    | 项目源码 | 文件源码
def draw_default(self):
        # draws default menu
        clear_bar = " " * (int(self.maxx*2/3))
        self.screen.addstr(2, 2, self.title, curses.A_STANDOUT) # Title for this menu
        self.screen.addstr(4, 2, self.subtitle, curses.A_BOLD) #Subtitle for this menu
        # clear menu on screen
        for index in range(len(self.options)+1):
            self.screen.addstr(5+index, 4, clear_bar, curses.A_NORMAL)
        # display all the menu items, showing the 'pos' item highlighted
        for index in range(len(self.options)):
            textstyle = self.normal
            if index == self.selected:
                textstyle = self.highlighted
            self.screen.addstr(5+index ,4, clear_bar, curses.A_NORMAL)
            self.screen.addstr(5+index ,4, "%d - %s" % (index+1, self.options[index]), textstyle)

        self.screen.addstr(11, 2, clear_bar, curses.A_NORMAL)
        self.screen.addstr(12, 2, clear_bar, curses.A_NORMAL)
        self.screen.addstr(11, 2, "plant: ", curses.A_DIM)
        self.screen.addstr(11, 9, self.plant_string, curses.A_NORMAL)
        self.screen.addstr(12, 2, "score: ", curses.A_DIM)
        self.screen.addstr(12, 9, self.plant_ticks, curses.A_NORMAL)

        # display fancy water gauge
        if not self.plant.dead:
            water_gauge_str = self.water_gauge()
            self.screen.addstr(5,14, water_gauge_str, curses.A_NORMAL)
        else:
            self.screen.addstr(5,13, clear_bar, curses.A_NORMAL)
            self.screen.addstr(5,13, " (   RIP   )", curses.A_NORMAL)

        # draw cute ascii from files
        self.draw_plant_ascii(self.plant)
项目:youtube_watcher    作者:Sjc1000    | 项目源码 | 文件源码
def video_options(self, item, position):
        if position == self.pos:
            return curses.color_pair(1)

        options = 0
        options |= curses.A_DIM if item['seen'] else 0
        options |= curses.color_pair(3) if item.get('fav') else 0

        if item['title'] in self.data:
            info = self.data[item['title']]
            options |= curses.A_UNDERLINE if info.get('watch') else 0

        if any(item['title'] == i['title'] for i in self.selected):
            options |= curses.A_REVERSE
        return options
项目:youtube_watcher    作者:Sjc1000    | 项目源码 | 文件源码
def draw_items(self):
        for y, i in enumerate(self.items[self.off:self.off+self.height-4]):
            if y == self.pos:
                options = curses.A_REVERSE
            else:
                options = 0
            if all(x['seen'] for x in self.data[i]['videos']):
                options |= curses.A_DIM
            title = ' {} '.format(i).ljust(self.width)
            self.screen.addstr(y+3, 0, title, options)
        return None