當前位置: 首頁>>代碼示例>>Python>>正文


Python curses.init_pair方法代碼示例

本文整理匯總了Python中curses.init_pair方法的典型用法代碼示例。如果您正苦於以下問題:Python curses.init_pair方法的具體用法?Python curses.init_pair怎麽用?Python curses.init_pair使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在curses的用法示例。


在下文中一共展示了curses.init_pair方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import init_pair [as 別名]
def __init__(self, enable=True):
        self.enable = enable
        if not self.enable:
            return
        self.logger = logging.getLogger('trader-logger')
        self.stdscr = curses.initscr()
        self.pad = curses.newpad(23, 120)
        self.order_pad = curses.newpad(10, 120)
        self.timestamp = ""
        self.last_order_update = 0
        curses.start_color()
        curses.noecho()
        curses.cbreak()
        curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_GREEN)
        curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_RED)
        self.stdscr.keypad(1)
        self.pad.addstr(1, 0, "Waiting for a trade...") 
開發者ID:mcardillo55,項目名稱:cbpro-trader,代碼行數:19,代碼來源:cursesDisplay.py

示例2: init_curses

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import init_pair [as 別名]
def init_curses():
    window = curses.initscr()
    curses.noecho() # prevents user input from being echoed
    curses.curs_set(0) # make cursor invisible

    curses.start_color()
    curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLACK)
    curses.init_pair(2, curses.COLOR_CYAN, curses.COLOR_BLACK)
    curses.init_pair(3, curses.COLOR_RED, curses.COLOR_BLACK)
    curses.init_pair(4, curses.COLOR_MAGENTA, curses.COLOR_BLACK)
    curses.init_pair(5, curses.COLOR_YELLOW, curses.COLOR_BLACK)

    window.timeout(50)
    window.keypad(1) # interpret arrow keys, etc

    return window 
開發者ID:esotericnonsense,項目名稱:bitcoind-ncurses,代碼行數:18,代碼來源:interface.py

示例3: init_curses

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import init_pair [as 別名]
def init_curses(self):
        """Setup the curses"""
        self.window = curses.initscr()
        self.height, self.width = self.window.getmaxyx()
        if self.width < 60:
            self.too_small = True
            return

        self.window.keypad(True)
        # self.window.nodelay(True)

        curses.noecho()
        curses.curs_set(False)
        curses.cbreak()
        curses.start_color()
        curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLACK)
        curses.init_pair(2, curses.COLOR_YELLOW, curses.COLOR_BLACK)
        curses.init_pair(3, curses.COLOR_WHITE, curses.COLOR_BLACK)
        curses.init_pair(4, curses.COLOR_GREEN, curses.COLOR_BLACK)
        curses.init_pair(5, curses.COLOR_WHITE, curses.COLOR_CYAN) 
開發者ID:Macr0phag3,項目名稱:email_hack,代碼行數:22,代碼來源:CLI.py

示例4: main

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import init_pair [as 別名]
def main():
    screen = init_curses()
    y, x = screen.getmaxyx()
    # create green
    curses.init_pair(1, curses.COLOR_GREEN, -1)
    # create red
    curses.init_pair(2, curses.COLOR_RED, -1) # -1 is default bcgd color
    # create white
    curses.init_pair(3, curses.COLOR_WHITE, -1)
    # create cyan
    curses.init_pair(4, curses.COLOR_CYAN, -1)
    # create yellow
    curses.init_pair(5, curses.COLOR_YELLOW, -1)
    # create black on white
    curses.init_pair(6, curses.COLOR_BLACK, curses.COLOR_WHITE)    
    # print the splash screen out!
    splash_screen(screen, y, x)
    

# check and see if this program is being run by itself
# if so call the main function 
開發者ID:JaredMHall,項目名稱:RaspberryCloud,代碼行數:23,代碼來源:raspcloud.py

示例5: main

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import init_pair [as 別名]
def main(stdscr, matches):
    curses.curs_set(False)
    selected = 0
    curses.init_pair(2, curses.COLOR_RED, curses.COLOR_BLACK)
    curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLACK)
    while True:
        printGames(stdscr, matches, selected)
        event = stdscr.getch()
        if event == ord("\n"):
            logging.info("Enter key pressed")
            return selected
        elif event == curses.KEY_UP:
            logging.info("Up key pressed")
            if selected != 0:
                selected -= 1
                printGames(stdscr,  matches,  selected)
        elif event == curses.KEY_DOWN:
            logging.info("Down key pressed")
            if selected != len(matches) - 1:
                selected += 1
                printGames(stdscr, matches,  selected) 
開發者ID:anubhavcodes,項目名稱:scorer.py,代碼行數:23,代碼來源:ui.py

示例6: _init_curses

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import init_pair [as 別名]
def _init_curses(self):
        self.stdscr = curses.initscr()
        self.stdscr.keypad(1)
        curses.noecho()
        curses.cbreak()
        curses.curs_set(0)
        curses.start_color()
        try:
            curses.init_pair(1, curses.COLOR_BLACK, 197)  # 接近機核主題的顏色
        except:
            # 樹莓派 windows無法使用機核like色
            curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_RED)
        curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_BLACK)
        self.stdscr.bkgd(curses.color_pair(2))
        self.stdscr.timeout(100)
        self.stdscr.refresh() 
開發者ID:yihong0618,項目名稱:gaycore,代碼行數:18,代碼來源:gcore_box.py

示例7: getcolor

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import init_pair [as 別名]
def getcolor():
    """color selection"""
    colors = {
        "red": 1,
        "green": 2,
        "yellow": 3,
        "blue": 4,
        "magenta": 5,
        "cyan": 6,
        "white": 7,
        "orange": 9,
        "random": random.randint(1, 255)
    }

    if color is not None and color.lower() in colors.keys():
        curses.init_pair(1, 0, -1)
        curses.init_pair(2, colors[color], -1)
        curses.init_pair(3, 0, colors[color])
    else:
        pass 
開發者ID:shaggytwodope,項目名稱:clockr,代碼行數:22,代碼來源:clockr.py

示例8: _setup_colour_pairs

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import init_pair [as 別名]
def _setup_colour_pairs(self):
        """
        Initialize all 63 color pairs based on the term:
        bg * 8 + 7 - fg
        So to get a color, we just need to use that term and get the right color
        pair number.
        """
        if not self.has_color:
            return

        for fg in xrange(8):
            for bg in xrange(8):
                # leave out white on black
                if fg == curses.COLOR_WHITE and \
                   bg == curses.COLOR_BLACK:
                    continue

                curses.init_pair(bg * 8 + 7 - fg, fg, bg) 
開發者ID:AnyMesh,項目名稱:anyMesh-Python,代碼行數:20,代碼來源:curses_display.py

示例9: setup

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import init_pair [as 別名]
def setup(self):
        curses.start_color()
        curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE)

        curses.cbreak()
        curses.echo()

        lines, cols = self.stdscr.getmaxyx()
        self.logwin = self.stdscr.subwin(lines - 2, cols, 0, 0)
        self.sepwin = self.stdscr.subwin(1, cols, lines - 2, 0)
        self.cmdwin = self.stdscr.subwin(1, cols, lines - 1, 0)

        self.logwin.scrollok(True)

        self.sepwin.bkgd(curses.color_pair(1))
        self.sepwin.refresh() 
開發者ID:flux3dp,項目名稱:fluxclient,代碼行數:18,代碼來源:console.py

示例10: setup_curses

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import init_pair [as 別名]
def setup_curses():
    """Setup terminal/curses state."""

    window = curses.initscr()
    curses.noecho()

    window = curses.newwin(
        WINDOW_HEIGHT + (VERT_PADDING * 2),
        WINDOW_WIDTH + (HORIZ_PADDING * 2),
        WINDOW_TOP - VERT_PADDING,
        WINDOW_LEFT - HORIZ_PADDING,
    )
    curses.start_color()

    global _COLOR_PAIRS
    _COLOR_PAIRS = {}
    for i, (k, v) in enumerate(COLOR_MAP.items(), 1):
        curses.init_pair(i, v, curses.COLOR_BLACK)
        _COLOR_PAIRS[k] = curses.color_pair(i)
    return window 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:22,代碼來源:space_invaders.py

示例11: setup

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import init_pair [as 別名]
def setup(stdscr):
    # curses
    curses.use_default_colors()
    curses.init_pair(1, curses.COLOR_RED, -1)
    curses.init_pair(2, curses.COLOR_RED, curses.COLOR_RED)
    curses.init_pair(3, curses.COLOR_GREEN, -1)
    curses.init_pair(4, -1, curses.COLOR_RED)
    try:
        curses.curs_set(False)
    except curses.error:
        # fails on some terminals
        pass
    stdscr.timeout(0)

    # prepare input thread mechanisms
    curses_lock = Lock()
    input_queue = Queue()
    quit_event = Event()
    return (curses_lock, input_queue, quit_event) 
開發者ID:trehn,項目名稱:termdown,代碼行數:21,代碼來源:termdown.py

示例12: _initialize_colors

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import init_pair [as 別名]
def _initialize_colors(self):
        """Function for initialzing curses colors. Called when CUI is first created.
        """

        # Start colors in curses
        curses.start_color()
        curses.init_pair(WHITE_ON_BLACK,    curses.COLOR_WHITE,     curses.COLOR_BLACK)
        curses.init_pair(BLACK_ON_GREEN,    curses.COLOR_BLACK,     curses.COLOR_GREEN)
        curses.init_pair(BLACK_ON_WHITE,    curses.COLOR_BLACK,     curses.COLOR_WHITE)
        curses.init_pair(WHITE_ON_RED,      curses.COLOR_WHITE,     curses.COLOR_RED)
        curses.init_pair(YELLOW_ON_BLACK,   curses.COLOR_YELLOW,    curses.COLOR_BLACK)
        curses.init_pair(RED_ON_BLACK,      curses.COLOR_RED,       curses.COLOR_BLACK)
        curses.init_pair(CYAN_ON_BLACK,     curses.COLOR_CYAN,      curses.COLOR_BLACK)
        curses.init_pair(MAGENTA_ON_BLACK,  curses.COLOR_MAGENTA,   curses.COLOR_BLACK)
        curses.init_pair(GREEN_ON_BLACK,    curses.COLOR_GREEN,     curses.COLOR_BLACK)
        curses.init_pair(BLUE_ON_BLACK,     curses.COLOR_BLUE,      curses.COLOR_BLACK) 
開發者ID:jwlodek,項目名稱:py_cui,代碼行數:18,代碼來源:__init__.py

示例13: show

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import init_pair [as 別名]
def show(self, screen):
        self.screen = screen

        curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK)
        self.white = curses.color_pair(1)

        curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_BLACK)
        self.green = curses.color_pair(2)

        curses.init_pair(3, curses.COLOR_YELLOW, curses.COLOR_BLACK)
        self.yellow = curses.color_pair(3)

        curses.init_pair(4, curses.COLOR_RED, curses.COLOR_BLACK)
        self.red = curses.color_pair(4)

        curses.curs_set(0)

        self.addstr(1, 1, 'BITNODES HARDWARE', self.white)
        self.addstr(1, 19, 'LOADING', self.yellow)

        while True:
            time.sleep(self.update()) 
開發者ID:ayeowch,項目名稱:bitnodes-hardware,代碼行數:24,代碼來源:lcd.py

示例14: setup_palette

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import init_pair [as 別名]
def setup_palette(class_):
        curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK)
        curses.init_pair(2, curses.COLOR_BLUE, curses.COLOR_BLACK)
        curses.init_pair(3, curses.COLOR_GREEN, curses.COLOR_BLACK)
        curses.init_pair(4, curses.COLOR_YELLOW, curses.COLOR_BLACK)
        curses.init_pair(5, curses.COLOR_RED, curses.COLOR_BLACK)
        curses.init_pair(6, curses.COLOR_CYAN, curses.COLOR_BLACK)
        curses.init_pair(7, curses.COLOR_MAGENTA, curses.COLOR_BLACK)
        curses.init_pair(8, curses.COLOR_WHITE, curses.COLOR_BLUE)
        curses.init_pair(9, curses.COLOR_WHITE, curses.COLOR_RED)

        class_.WHITE = curses.color_pair(1)
        class_.BLUE = curses.color_pair(2)
        class_.GREEN = curses.color_pair(3)
        class_.YELLOW = curses.color_pair(4)
        class_.RED = curses.color_pair(5)
        class_.CYAN = curses.color_pair(6)
        class_.MAGENTA = curses.color_pair(7)
        class_.WHITE_ON_BLUE = curses.color_pair(8)
        class_.WHITE_ON_RED = curses.color_pair(9)

        class_.HASHTAG = class_.BLUE | curses.A_BOLD 
開發者ID:ihabunek,項目名稱:toot,代碼行數:24,代碼來源:app.py

示例15: init_colors

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import init_pair [as 別名]
def init_colors(self):

        if curses.has_colors() and curses.can_change_color():
            curses.init_color(self.COLOR_BLACK, 0, 0, 0)
            curses.init_color(self.COLOR_WHITE, 1000, 1000, 1000)
            curses.init_color(self.COLOR_BLUE, 0, 0, 1000)
            curses.init_color(self.COLOR_RED, 1000, 0, 0)
            curses.init_color(self.COLOR_GREEN, 0, 1000, 0)

            for i in xrange(0, self.GRAYS):
                curses.init_color(
                        self.GRAY_BASE + i,
                        i * 1000 / (self.GRAYS - 1),
                        i * 1000 / (self.GRAYS - 1),
                        i * 1000 / (self.GRAYS - 1)
                        )
                curses.init_pair(
                        self.GRAY_BASE + i,
                        self.GRAY_BASE + i,
                        self.COLOR_BLACK
                        )

        else:
            self.COLOR_BLACK = curses.COLOR_BLACK
            self.COLOR_WHITE = curses.COLOR_WHITE
            self.COLOR_BLUE = curses.COLOR_BLUE
            self.COLOR_RED = curses.COLOR_RED
            self.COLOR_GREEN = curses.COLOR_GREEN

            for i in xrange(0, self.GRAYS):
                curses.init_pair(
                        self.GRAY_BASE + i,
                        self.COLOR_WHITE,
                        self.COLOR_BLACK
                        )

        curses.init_pair(self.BLACK, self.COLOR_BLACK, self.COLOR_BLACK)
        curses.init_pair(self.WHITE, self.COLOR_WHITE, self.COLOR_BLACK)
        curses.init_pair(self.BLUE, self.COLOR_BLUE, self.COLOR_BLACK)
        curses.init_pair(self.RED, self.COLOR_RED, self.COLOR_BLACK)
        curses.init_pair(self.GREEN, self.COLOR_GREEN, self.COLOR_BLACK) 
開發者ID:Battelle,項目名稱:sandsifter,代碼行數:43,代碼來源:gui.py


注:本文中的curses.init_pair方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。