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


Python curses.newwin方法代码示例

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


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

示例1: search

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newwin [as 别名]
def search(self):
        """Open search window, get input and set the search string."""
        if self.init_search is not None:
            return
        scr2 = curses.newwin(3, self.max_x, self.max_y - 3, 0)
        scr3 = scr2.derwin(1, self.max_x - 12, 1, 9)
        scr2.box()
        scr2.move(1, 1)
        addstr(scr2, "Search: ")
        scr2.refresh()
        curses.curs_set(1)
        self._search_win_open = 3
        self.textpad = Textbox(scr3, insert_mode=True)
        self.search_str = self.textpad.edit(self._search_validator)
        self.search_str = self.search_str.lower().strip()
        try:
            curses.curs_set(0)
        except _curses.error:
            pass
        if self.search_str:
            self.init_search = None
        self._search_win_open = 0 
开发者ID:OpenTrading,项目名称:OpenTrader,代码行数:24,代码来源:tabview.py

示例2: _calculate_layout

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newwin [as 别名]
def _calculate_layout(self):
        """Setup popup window and format data. """
        self.scr.touchwin()
        self.term_rows, self.term_cols = self.scr.getmaxyx()
        self.box_height = self.term_rows - int(self.term_rows / 2)
        self.win = curses.newwin(int(self.term_rows / 2),
                                 self.term_cols, self.box_height, 0)
        try:
            curses.curs_set(False)
        except _curses.error:
            pass
        # transform raw data into list of lines ready to be printed
        s = self.data.splitlines()
        s = [wrap(i, self.term_cols - 3, subsequent_indent=" ")
             or [""] for i in s]
        self.tdata = [i for j in s for i in j]
        # -3 -- 2 for the box lines and 1 for the title row
        self.nlines = min(len(self.tdata), self.box_height - 3)
        self.scr.refresh() 
开发者ID:OpenTrading,项目名称:OpenTrader,代码行数:21,代码来源:tabview.py

示例3: show_nmea

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newwin [as 别名]
def show_nmea():
    """NMEA output in curses terminal"""
    data_window = curses.newwin(24, 79, 0, 0)

    for new_data in gpsd_socket:
        if new_data:
            screen.nodelay(1)
            key_press = screen.getch()
            if key_press == ord('q'):
                shut_down()
            elif key_press == ord('j'):  # raw
                gpsd_socket.watch(enable=False, gpsd_protocol='nmea')
                gpsd_socket.watch(gpsd_protocol='json')
                show_human()

            data_window.border(0)
            data_window.addstr(0, 2, 'GPS3 Python {}.{}.{} GPSD Interface Showing NMEA protocol'.format(*sys.version_info), curses.A_BOLD)
            data_window.addstr(2, 2, '{}'.format(gpsd_socket.response))
            data_window.refresh()
        else:
            sleep(.1) 
开发者ID:wadda,项目名称:gps3,代码行数:23,代码来源:human.py

示例4: show_nmea

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newwin [as 别名]
def show_nmea():
    """NMEA output in curses terminal"""
    data_window = curses.newwin(24, 79, 0, 0)

    for new_data in gpsd_socket:
        if new_data:
            screen.nodelay(1)
            key_press = screen.getch()
            if key_press == ord('q'):
                shut_down()
            elif key_press == ord('j'):  # raw
                gpsd_socket.watch(enable=False, gpsd_protocol='nmea')
                gpsd_socket.watch(gpsd_protocol='json')
                show_human()

            data_window.border(0)
            data_window.addstr(0, 2, 'AGPS3 Python {}.{}.{} GPSD Interface Showing NMEA protocol'.format(*sys.version_info), curses.A_BOLD)
            data_window.addstr(2, 2, '{}'.format(gpsd_socket.response))
            data_window.refresh()
        else:
            sleep(.1) 
开发者ID:wadda,项目名称:gps3,代码行数:23,代码来源:ahuman.py

示例5: popup_listbox

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newwin [as 别名]
def popup_listbox(title, output, par_widget):
    """
    It opens a centered popup. output is an instance of the class Output.
    Returns (bool, line number of the cursor)
    """
    h2 = par_widget.height * 3 // 4
    w2 = par_widget.width * 6 // 7

    x = (par_widget.width - w2) // 2 - 1
    y = (par_widget.height - h2) // 2 - 1

    # A background with borders
    borders = curses.newwin(h2 + 2, w2 + 2, par_widget.y + y, par_widget.x + x)
    borders.border()
    borders.addstr(0, (w2 - len(title)) // 2, " %s " % title)
    borders.refresh()

    w = Window()
    w.screen = borders

    w.widgets.append(Listbox(par_widget.x + x + 1, par_widget.y + y + 1,
                             w2, h2, output))
    ret = w.start_view(w.screen)

    return (ret, w.widgets[0].win_y + w.widgets[0].cursor_y) 
开发者ID:plasma-disassembler,项目名称:plasma,代码行数:27,代码来源:utils.py

示例6: popup_inputbox

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newwin [as 别名]
def popup_inputbox(title, text, par_widget):
    """
    It opens a centered popup and returns the text entered by the user.
    """
    h2 = 1
    w2 = par_widget.width * 6 // 7

    x = (par_widget.width - w2) // 2 - 1 + par_widget.x
    y = (par_widget.height - h2) // 2 - 1 + par_widget.y

    # A background with borders
    borders = curses.newwin(h2 + 2, w2 + 2, y, x)
    borders.border()
    borders.addstr(0, (w2 - len(title)) // 2, " %s " % title)
    borders.refresh()

    return inputbox(text, x + 1, y + 1, w2, h2) 
开发者ID:plasma-disassembler,项目名称:plasma,代码行数:19,代码来源:utils.py

示例7: test_textpad

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newwin [as 别名]
def test_textpad(stdscr, insert_mode=False):
    ncols, nlines = 8, 3
    uly, ulx = 3, 2
    if insert_mode:
        mode = 'insert mode'
    else:
        mode = 'overwrite mode'

    stdscr.addstr(uly-3, ulx, "Use Ctrl-G to end editing (%s)." % mode)
    stdscr.addstr(uly-2, ulx, "Be sure to try typing in the lower-right corner.")
    win = curses.newwin(nlines, ncols, uly, ulx)
    textpad.rectangle(stdscr, uly-1, ulx-1, uly + nlines, ulx + ncols)
    stdscr.refresh()

    box = textpad.Textbox(win, insert_mode)
    contents = box.edit()
    stdscr.addstr(uly+ncols+2, 0, "Text entered in the box\n")
    stdscr.addstr(repr(contents))
    stdscr.addstr('\n')
    stdscr.addstr('Press any key')
    stdscr.getch()

    for i in range(3):
        stdscr.move(uly+ncols+2 + i, 0)
        stdscr.clrtoeol() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:27,代码来源:curses_tests.py

示例8: draw_window

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newwin [as 别名]
def draw_window(state, window):
    window.clear()
    window.refresh()
    win_header = curses.newwin(2, 76, 0, 0)

    unit = 'BTC'
    if 'testnet' in state:
        if state['testnet']:
            unit = 'TNC'

    if 'wallet' in state:
        if 'balance' in state:
            balance_string = "balance: " + "%0.8f" % state['balance'] + " " + unit
            if 'unconfirmedbalance' in state:
                if state['unconfirmedbalance'] != 0:
                    balance_string += " (+" + "%0.8f" % state['unconfirmedbalance'] + " unconf)"
            window.addstr(0, 1, balance_string, curses.A_BOLD)

        draw_transactions(state)

    else:
        win_header.addstr(0, 1, "no wallet information loaded", curses.A_BOLD + curses.color_pair(3))
        win_header.addstr(1, 1, "loading... (is -disablewallet on?)", curses.A_BOLD)

    win_header.refresh() 
开发者ID:esotericnonsense,项目名称:bitcoind-ncurses,代码行数:27,代码来源:wallet.py

示例9: draw_transactions

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newwin [as 别名]
def draw_transactions(state):
    window_height = state['y'] - 3
    win_transactions = curses.newwin(window_height, 76, 2, 0)

    win_transactions.addstr(0, 1, "transactions:                               (UP/DOWN: scroll, ENTER: view)", curses.A_BOLD + curses.color_pair(5))

    offset = state['wallet']['offset']

    for index in range(offset, offset+window_height-1):
        if index < len(state['wallet']['view_string']):
                condition = (index == offset+window_height-2) and (index+1 < len(state['wallet']['view_string']))
                condition = condition or ( (index == offset) and (index > 0) )

                if condition:
                    win_transactions.addstr(index+1-offset, 1, "...")
                else:
                    win_transactions.addstr(index+1-offset, 1, state['wallet']['view_string'][index])

                if index == (state['wallet']['cursor']*4 + 1):
                    win_transactions.addstr(index+1-offset, 1, ">", curses.A_REVERSE + curses.A_BOLD)

    win_transactions.refresh() 
开发者ID:esotericnonsense,项目名称:bitcoind-ncurses,代码行数:24,代码来源:wallet.py

示例10: draw_window

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newwin [as 别名]
def draw_window(state):
    win_footer = curses.newwin(1, 76, state['y']-1, 0)

    color = curses.color_pair(1)
    if 'testnet' in state:
        if state['testnet']:
            color = curses.color_pair(2)

    win_footer.addstr(0, 1, "ncurses", color + curses.A_BOLD)

    x = 10
    for mode_string in g.modes:
        modifier = curses.A_BOLD
        if state['mode'] == mode_string:
            modifier += curses.A_REVERSE
        win_footer.addstr(0, x, mode_string[0].upper(), modifier + curses.color_pair(5)) 
        win_footer.addstr(0, x+1, mode_string[1:], modifier)
        x += len(mode_string) + 2

    win_footer.refresh() 
开发者ID:esotericnonsense,项目名称:bitcoind-ncurses,代码行数:22,代码来源:footer.py

示例11: draw_window

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newwin [as 别名]
def draw_window(state, window):
    window.clear()
    window.refresh()

    win_header = curses.newwin(3, 75, 0, 0)

    if 'peerinfo' in state:
        win_header.addstr(0, 1, "connected peers: " + str(len(state['peerinfo'])).ljust(10) + "                             (UP/DOWN: scroll)", curses.A_BOLD)
        win_header.addstr(2, 1, "  Node IP              Version        Recv      Sent         Time  Height", curses.A_BOLD + curses.color_pair(5))
        draw_peers(state)

    else:
        win_header.addstr(0, 1, "no peer information loaded", curses.A_BOLD + curses.color_pair(3))
        win_header.addstr(1, 1, "loading...", curses.A_BOLD)

    win_header.refresh() 
开发者ID:esotericnonsense,项目名称:bitcoind-ncurses,代码行数:18,代码来源:peers.py

示例12: draw_window

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newwin [as 别名]
def draw_window(state, window):
    window.clear()
    window.refresh()

    win_header = curses.newwin(3, 75, 0, 0)

    if 'chaintips' in state:
        win_header.addstr(0, 1, "chain tips: " + str(len(state['chaintips'])).ljust(10) + "                 (UP/DOWN: scroll, F: refresh)", curses.A_BOLD)
        win_header.addstr(1, 1, "key: Active/Invalid/HeadersOnly/ValidFork/ValidHeaders", curses.A_BOLD)
        win_header.addstr(2, 1, "height length status 0-prefix hash", curses.A_BOLD + curses.color_pair(5))
        draw_tips(state)

    else:
        win_header.addstr(0, 1, "no chain tip information loaded", curses.A_BOLD + curses.color_pair(3))
        win_header.addstr(1, 1, "loading... (press F to try again)", curses.A_BOLD)

    win_header.refresh() 
开发者ID:esotericnonsense,项目名称:bitcoind-ncurses,代码行数:19,代码来源:forks.py

示例13: init_layout

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newwin [as 别名]
def init_layout(self):
        """Initialize the each windows with their size and shape"""
        self.height, self.width = self.window.getmaxyx()

        # Title section
        self.window.addstr(0, 0, '[awesome-{}] Find awesome things!'.format(self.awesome_title), curses.color_pair(1))
        self.window.hline(1, 0, curses.ACS_HLINE, self.width)

        # Search result section
        self.result_window = curses.newwin(self.height - 4, self.width, 2, 0)
        self.result_window.keypad(True)

        # Search bar section
        self.window.hline(self.height - 2, 0, curses.ACS_HLINE, self.width)
        self.window.addch(self.height - 1, 0, '>')
        self.search_window = curses.newwin(1, self.width - 1, self.height - 1, 2)
        self.search_window.keypad(True)

        self.window.refresh() 
开发者ID:mingrammer,项目名称:awesome-finder,代码行数:21,代码来源:tui.py

示例14: __init__

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newwin [as 别名]
def __init__(self, screen):
        self.screen = screen

        # Set default values
        self.max_db = 50.0
        self.min_db = -20.0
        self.threshold_db = 20.0

        # Create a window object in top half of the screen, within the border
        screen_dims = screen.getmaxyx()
        height = int(screen_dims[0]/2.0)
        width = screen_dims[1]-2
        self.win = curses.newwin(height, width, 1, 1)
        self.dims = self.win.getmaxyx()

        # Right end of window resreved for string of N charachters
        self.chars = 7 
开发者ID:madengr,项目名称:ham2mon,代码行数:19,代码来源:cursesgui.py

示例15: __init__

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newwin [as 别名]
def __init__(self, pos, page_number, box, box_info):
        """
        Construct the class
        :param self: ApDisplayInfo
        :param pos: position of the line in the ap selection page
        :param page_number: page number of the ap selection
        :param box: the curses.newwin.box object containing ap information
        :param key: the key user have keyed in
        :param box_info: list of window height, window len, and max row number
        :type self: ApDisplayInfo
        :type pos: int
        :type page_number: int
        :type box: curse.newwin.box
        :type key: str
        :return: None
        :rtype: None
        """

        self.pos = pos
        self.page_number = page_number
        self.box = box
        # list of (max_win_height, max_win_len, max_row, key)
        self._box_info = box_info 
开发者ID:wifiphisher,项目名称:wifiphisher,代码行数:25,代码来源:tui.py


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