python类A_BOLD的实例源码

ncurses.py 文件源码 项目:isar 作者: ilbers 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def setStatus(self, status):
            while len(status) < MAXSTATUSLENGTH:
                status = status + " "
            self.decoration.setText( self.StatusPosition, 1, status, curses.A_BOLD )


    #-------------------------------------------------------------------------#
widget.py 文件源码 项目:grbl-stream 作者: fragmuffin 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def render(self, strong=False):
        addstr_params = [self.row, self.col, '[{}]'.format(self.label)]
        if strong:
            addstr_params.append(curses.A_BOLD)
        self.window.addstr(*addstr_params)
widget.py 文件源码 项目:grbl-stream 作者: fragmuffin 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def render(self, strong=False):
        (y, x) = self.window.getmaxyx()
        label_str = " {} ".format(self._label)
        addstr_params = [
            self.row, self.label_col, " {} ".format(self._label),
            curses.color_pair(self.color_index) if curses.has_colors() else 0
        ]

        # heading attributes
        attrs = curses.color_pair(self.color_index) if curses.has_colors() else 0
        if strong:
            attrs |= curses.A_BOLD

        self.window.hline(0, 0, curses.ACS_HLINE, x)
        self.window.addstr(self.row, self.label_col, " {} ".format(self._label), attrs)
menu.py 文件源码 项目:aws-ec2rescue-linux 作者: awslabs 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def _draw_menu(self, screen):
        """
        Given a menu window, draw the rows including the header and the scrollable rows representing menu items.

        Parameters:
            screen (WindowObject): the window that will be drawn to
        """
        # Add the header
        screen.addstr(0, int((curses.COLS - 6) / 2 - len(self.header) / 2),
                      self.header,
                      curses.A_BOLD)

        # Add each item to the menu
        for row in range(1 + (self.max_displayed_rows * (self.current_page - 1)),
                         self.max_displayed_rows + 1 +
                         (self.max_displayed_rows * (self.current_page - 1))):
            # Pad or truncate the module name to 40 characters
            row_item_name = "{:40}".format(str(self._items[row - 1])[:40])
            # Truncate the row's string to the drawable width
            display_str = str(row_item_name + "  " + self._items[row - 1].row_right)[:curses.COLS - 6]
            # Draw the row
            if row + (self.max_displayed_rows * (self.current_page - 1)) == \
                self.current_row + \
                    (self.max_displayed_rows * (self.current_page - 1)):
                # Highlight the item that is currently selected
                screen.addstr(row - (self.max_displayed_rows * (self.current_page - 1)),
                              1,
                              display_str.rstrip(),
                              curses.color_pair(1) | curses.A_BOLD)
            else:
                screen.addstr(row - (self.max_displayed_rows * (self.current_page - 1)),
                              1,
                              display_str)

            # Stop printing items when the end of the drawable space is reached
            if row == self.num_rows:
                break
curses_reporter.py 文件源码 项目:copycat 作者: LSaldyt 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def slipnode_name_and_attr(self, slipnode):
        if slipnode.activation == 100:
            return (slipnode.name.upper(), curses.A_STANDOUT)
        if slipnode.activation > 50:
            return (slipnode.name.upper(), curses.A_BOLD)
        else:
            return (slipnode.name.lower(), curses.A_NORMAL)
xmas.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def star():
    treescrn2.attrset(curses.A_BOLD | curses.A_BLINK)
    set_color(treescrn2, curses.COLOR_YELLOW)

    treescrn2.addch(0, 12, ord('*'))
    treescrn2.standend()

    unset_color(treescrn2)
    treescrn2.refresh()
    w_del_msg.refresh()
    return
xmas.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def strng1():
    treescrn2.attrset(curses.A_BOLD | curses.A_BLINK)
    set_color(treescrn2, curses.COLOR_WHITE)

    treescrn2.addch(3, 13, ord('\''))
    treescrn2.addch(3, 12, ord(':'))
    treescrn2.addch(3, 11, ord('.'))

    treescrn2.attroff(curses.A_BOLD | curses.A_BLINK)
    unset_color(treescrn2)

    treescrn2.refresh()
    w_del_msg.refresh()
    return
ncurses.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def mkpanel(color, rows, cols, tly, tlx):
    win = curses.newwin(rows, cols, tly, tlx)
    pan = panel.new_panel(win)
    if curses.has_colors():
        if color == curses.COLOR_BLUE:
            fg = curses.COLOR_WHITE
        else:
            fg = curses.COLOR_BLACK
        bg = color
        curses.init_pair(color, fg, bg)
        win.bkgdset(ord(' '), curses.color_pair(color))
    else:
        win.bkgdset(ord(' '), curses.A_BOLD)

    return pan
rain.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def next_j(j):
    if j == 0:
        j = 4
    else:
        j -= 1

    if curses.has_colors():
        z = randrange(0, 3)
        color = curses.color_pair(z)
        if z:
            color = color | curses.A_BOLD
        stdscr.attrset(color)

    return j
ascii_qgis.py 文件源码 项目:ascii_qgis 作者: NathanW2 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def render_map(self):
        y, x = scr.getmaxyx()
        x -= 30

        self.mapwin.clear()
        self.mapwin.box()
        self.mapwin.addstr(0, 2, self.title, curses.A_BOLD)

        height, width = self.mapwin.getmaxyx()
        # Only render the image if we have a open project
        if not self.settings and project:
            self.settings = project.map_settings

        if project:
            settings = self.settings
            data = generate_layers_ascii(self.settings, width, height)
            for row, rowdata in enumerate(data, start=1):
                if row >= height:
                    break

                for col, celldata in enumerate(rowdata, start=1):
                    if col >= width - 1:
                        break

                    value, color = celldata[0], celldata[1]
                    if value == ' ':
                        color = 8
                    if not ascii_mode_enabled:
                        value = ' '

                    if not color_mode_enabled:
                        color = 0

                    self.mapwin.addstr(row, col, value, curses.color_pair(color))

        self.mapwin.refresh()
ui.py 文件源码 项目:youtube_watcher 作者: Sjc1000 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def create_list(self, get_input=True):
        self.screen.clear()
        self.height, self.width = self.screen.getmaxyx()
        self.screen.addstr(self.title.center(self.width),
                           curses.color_pair(1) | curses.A_BOLD)
        self.screen.addstr(self.comment.center(self.width))
        self.draw_items()
        if not get_input:
            return None
        return self.screen.getch()
reporter.py 文件源码 项目:trtop 作者: aol 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def _print_header(self):
        row = 0
        self._print_line(row, 0, "TCP Remote TOP", color=curses.A_BOLD)
        self._print_line(row, 2, " - " + self.config_subtitle)

        row = 1
        self._print_line(row, 2, "Connections", color=curses.A_BOLD)
        self._print_line(row, 14, "Transport", color=curses.A_BOLD)
        self._print_line(row, 17, "Pcap", color=curses.A_BOLD)

        row = 3
        self._print_line(row, 0, "Host", color=curses.A_UNDERLINE)
        self._print_line(row, 2, "Syn(/s)", color=curses.A_UNDERLINE)
        self._print_line(row, 4, "Syn/Ack(%)", color=curses.A_UNDERLINE)
        self._print_line(row, 6, "Est(%)", color=curses.A_UNDERLINE)
        self._print_line(row, 8, "Rst(%)", color=curses.A_UNDERLINE)
        self._print_line(row, 9, "Fin_O(%)", color=curses.A_UNDERLINE)
        self._print_line(row, 10, "Fin_I(%)", color=curses.A_UNDERLINE)
        self._print_line(row, 11, "Est Rate", color=curses.A_UNDERLINE)
        self._print_line(row, 12, "QoS", color=curses.A_UNDERLINE)
        self._print_line(row, 13, "Lat", color=curses.A_UNDERLINE)

        self._print_line(row, 14, "Out", color=curses.A_UNDERLINE)
        self._print_line(row, 15, "In", color=curses.A_UNDERLINE)
        self._print_line(row, 16, "Rtt", color=curses.A_UNDERLINE)

        self._print_line(row, 17, "Err", color=curses.A_UNDERLINE)

        row = 4
        self._print_line(row, 2, "")
        return row + 1
reporter.py 文件源码 项目:trtop 作者: aol 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def _print_totals(self, totals, row):
        row += 1
        self._print_line(row, 0, 'Totals:', color=curses.A_BOLD)
        self._print_line(row, 2, "{0} ({1:.2f})".format(totals['syn_count'], totals['syn_rate']), color=curses.A_BOLD)
        self._print_line(row, 6, "{0} ({1:.2f})".format(totals['est_count'], totals['est_rate']), color=curses.A_BOLD)
        self._print_line(row, 8, str(totals['rst_count']), color=curses.A_BOLD)

        row += 1
        self._print_line(row, 0, "")
        return row + 1
yate_console.py 文件源码 项目:YATE 作者: GarethNelson 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def draw_status(self):
       self.scr.addstr(self.y+1,self.x+1,' '*(self.w-2),curses.color_pair(TOPSTATUS))
       self.scr.addstr(self.y+2,self.x+1,' '*(self.w-2),curses.color_pair(TOPSTATUS))
       self.scr.addstr(self.y+1,self.x+2,'Connection status: ',curses.color_pair(TOPSTATUS))
       if self.client.is_connected():
          self.scr.addstr(self.y+1,self.x+21,'Online ',curses.color_pair(TOPSTATUS_ONLINE)|curses.A_BOLD)
          self.scr.addstr(self.y+1,self.x+28,'Status: %s' % self.get_status_str(),curses.color_pair(TOPSTATUS)|curses.A_BOLD)
          self.scr.addstr(self.y+2,self.x+2,'[Q quit] [V voxel view] [L log view] [H health view] [I inventory view] [/ enter command] [wasd manual move]',curses.color_pair(TOPSTATUS))
       else:
          self.scr.addstr(self.y+1,self.x+21,'Offline',curses.color_pair(TOPSTATUS_OFFLINE)|curses.A_BOLD)
          self.scr.addstr(self.y+2,self.x+2,'Press C to connect and Q to quit',curses.color_pair(TOPSTATUS))
WsjtxCurses.py 文件源码 项目:py_wsjtx 作者: teabreakninja 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def add_cq(self, the_text, colour, loc, country, info):
        self.main_win.addstr("CQ CALLED BY ")
        self.main_win.addstr("{}".format(the_text), curses.color_pair(colour)|curses.A_BOLD)
        self.main_win.addstr(" [{}] {}\n".format(loc, country))
        self.main_win.addstr("  [Call:{}, & Band:{}, Country:{}, & Band:{}]\n".format(
            self.convert(info["call"]),
            self.convert(info["call_band"]),
            self.convert(info["country"]),
            self.convert(info["country_band"])
        ))
        self.main_win.refresh()
        self.stdscr.refresh()
curses_display.py 文件源码 项目:Adwear 作者: Uberi 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def _setattr(self, a):
        if a is None:
            self.s.attrset(0)
            return
        elif not isinstance(a, AttrSpec):
            p = self._palette.get(a, (AttrSpec('default', 'default'),))
            a = p[0]

        if self.has_color:
            if a.foreground_basic:
                if a.foreground_number >= 8:
                    fg = a.foreground_number - 8
                else:
                    fg = a.foreground_number
            else:
                fg = 7

            if a.background_basic:
                bg = a.background_number
            else:
                bg = 0

            attr = curses.color_pair(bg * 8 + 7 - fg)
        else:
            attr = 0

        if a.bold:
            attr |= curses.A_BOLD
        if a.standout:
            attr |= curses.A_STANDOUT
        if a.underline:
            attr |= curses.A_UNDERLINE
        if a.blink:
            attr |= curses.A_BLINK

        self.s.attrset(attr)
main.py 文件源码 项目:satori-rtm-sdk-python 作者: satori-com 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def render_chat(users, history, screen, x, y, w, h):
    for (i, a) in enumerate(history[-h:]):
        buffer = []
        if 'user' in a:
            if a['user'] in users:
                user_attr = curses.A_BOLD
            else:
                user_attr = curses.A_NORMAL
            if a['message'].startswith('/me '):
                text = '* {0} {1}'.format(a['user'], a['message'][4:])
                buffer = [
                    ('* ', curses.A_NORMAL),
                    (a['user'], user_attr),
                    (u' {0}'.format(a['message'][4:]), curses.A_NORMAL)]
            else:
                buffer = [
                    (a['user'], user_attr),
                    (u'> {0}'.format(a['message']), curses.A_NORMAL)]
        else:
            buffer = [(u'* {0}'.format(a), curses.A_NORMAL)]
        x_ = x + 1
        for (text, attr) in buffer:
            if not isinstance(text, six.binary_type):
                text = text.encode('utf8')
            screen.addstr(y + 1 + i, x_, text, attr)
            x_ += len(text.decode('utf8'))
recipe-577933.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def getStats(scr):
    curses.init_pair(9,  curses.COLOR_WHITE,  curses.COLOR_BLACK)
    curses.init_pair(10, curses.COLOR_YELLOW, curses.COLOR_BLACK)
    curses.init_pair(11, curses.COLOR_RED,    curses.COLOR_BLACK)
    curses.init_pair(12, curses.COLOR_GREEN,  curses.COLOR_BLACK)
    (maxY, maxX) = scr.getmaxyx()
    while 1:
        try:
            display_time(scr)
            display_loadavg(scr)
            display_header(scr)
            #write(scr, 3, 0, '%-4s %-20s %-15s %-40s%s' % ('Slot', 'Remote Host', 'State', 'Filename', ' '*(maxX-83)), curses.A_BOLD)
            cnt = 5
            try:
                for i in os.listdir(DISTCC_DIR+'/state'):
                    data = struct.unpack('@iLL128s128siiP', open(DISTCC_DIR+'/state/'+i).readline().strip())
                    file = data[3].split('\x00')[0] or 'None'
                    host = data[4].split('\x00')[0] or 'None'
                    slot = int(data[5])
                    stte = states[int(data[6])]
                    scr.move(cnt,0)
                    scr.clrtoeol()
                    if 'None' not in (file, host):
                        write(scr, cnt, 0, '%s' % slot, curses.color_pair(9))
                        write(scr, cnt, 5, '%s' % host, curses.color_pair(9))
                        if int(data[6]) in (2,3):
                            write(scr, cnt, 25, '%s ' % (stte), curses.color_pair(10))
                        elif int(data[6]) in (0,1):
                            write(scr, cnt, 25, '%s ' % (stte), curses.color_pair(11))
                        elif int(data[6]) in (4,5):
                            write(scr, cnt, 25, '%s ' % (stte), curses.color_pair(12))
                        elif int(data[6]) in (6,7):
                            write(scr, cnt, 25, '%s ' % (stte), curses.color_pair(12)|curses.A_BOLD)
                        else: write(scr, cnt, 25, '%s ' % (stte))
                        write(scr, cnt, 45, '%s' % file, curses.color_pair(9))
                        cnt += 1
            except struct.error: pass
            except IOError: pass
            scr.refresh()
            time.sleep(0.75)
            scr.erase()
            scr.move(0,0)
        except KeyboardInterrupt:
            sys.exit(-1)
menu.py 文件源码 项目:new 作者: atlj 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def create(liste):
    screen = curses.initscr()
    curses.start_color()
    curses.init_pair(1,curses.COLOR_RED, curses.COLOR_WHITE)
    s = curses.color_pair(1)
    h = curses.A_NORMAL
    pos = 0

    while 1:
        curses.noecho()
        screen.clear()
        screen.border(0)
        screen.keypad(True)
        screen.addstr(1,2,"(w)Yukari/Up (s)Asagi/Down (e)Sec", curses.A_BOLD)
        a = 0
        b = 4
        c = 3
        for oge in liste:
            if int(a/15)<1:
                if pos == a:
                    screen.addstr(b, 4, "".join(liste[a]), s)
                else:
                    screen.addstr(b, 4, "".join(liste[a]), h)
            else:
                c = c + 1
                if pos == a:
                    screen.addstr(c, 23, "".join(liste[a]), s)
                else:
                    screen.addstr(c, 23, "".join(liste[a]), h)


            a = a + 1
            b = b + 1
        screen.refresh()
        try:
            inp = screen.getkey(1,1)

            if inp == 'e':
                screen.refresh()
                curses.echo()
                screen.keypad(False)
                curses.endwin()
                break
            if inp == 'w':
                if pos > 0:
                    pos = pos - 1
                else:
                    pos = len(liste)-1
            if inp== 's':
                if pos < len(liste)-1:
                    pos = pos + 1
                else:
                    pos=0
        except Exception as e:
            pass
    return pos
tolerance.py 文件源码 项目:hurt 作者: io-digital 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def update_ui_worker():
    global main_start, total_seconds, _timeout, hits, workers, status, test_number, total_seconds, test_start, \
        test_stop, requests_handled, test_seconds, _tolerance, _url, break_out

    while True:

        rc = utils.render_result_codes(result_codes, timeout_count, connection_error_count)

        if not q.empty() and main_start:
            total_seconds = time.time()-main_start

        screen.addstr(1, 2, 'PAIN TOLERANCE on %s' % _url, curses.color_pair(3)|curses.A_BOLD)

        screen.addstr(3, 2, 'Status: %s                             ' % status)

        screen.addstr(5, 2, 'Trying %s hits with %s workers          ' % (hits, workers))
        screen.addstr(6, 2, 'Timeout: %s seconds                     ' % (_timeout,))
        screen.addstr(6, 40, 'Tolerance: %s errors                   ' % (_tolerance,))

        screen.addstr(7, 2, 'Active Workers: %s       ' % (threading.active_count() - 2))
        screen.addstr(7, 40, 'Queue: %s        ' % q.qsize())

        if test_start is None:
            test_seconds = 0

        else:
            if test_stop is None:
                test_seconds = time.time() - test_start
            else:
                test_seconds = test_stop - test_start

        screen.addstr(9, 2, 'Test Seconds: %.2f         ' % test_seconds)
        screen.addstr(9, 40, 'Requests handled: %s      ' % requests_handled)

        if result_codes and test_seconds and '200 OK' in result_codes:
            screen.addstr(10, 2, 'Requests per second: %.2f      ' % (int(result_codes['200 OK']) / test_seconds), )

        if durations:
            screen.addstr(10, 40, 'Average Request: %.2f seconds     ' % (reduce(lambda x, y: x + y, durations) / len(durations)))

        screen.addstr(12, 2, rc)

        screen.refresh()
        time.sleep(0.1)


问题


面经


文章

微信
公众号

扫码关注公众号