Python curses.newwin() Examples

The following are 30 code examples of curses.newwin(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module curses , or try the search function .
Example #1
Source File: curses_tests.py    From ironpython2 with Apache License 2.0 7 votes vote down vote up
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() 
Example #2
Source File: tui.py    From awesome-finder with MIT License 6 votes vote down vote up
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() 
Example #3
Source File: tabview.py    From OpenTrader with GNU Lesser General Public License v3.0 6 votes vote down vote up
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() 
Example #4
Source File: termpdf.py    From termpdf.py with MIT License 6 votes vote down vote up
def create_text_win(self, length, header):
        # calculate dimensions
        w = max(self.cols - 4, 60)
        h = self.rows - 2
        x = int(self.cols / 2 - w / 2)
        y = 1

        win = curses.newwin(h,w,y,x)
        win.box()
        win.addstr(1,2, '{:^{l}}'.format(header, l=(w-3)))
        
        self.stdscr.clear()
        self.stdscr.refresh()
        win.refresh()
        pad = curses.newpad(length,1000)
        pad.keypad(True)
        
        return win, pad 
Example #5
Source File: utils.py    From plasma with GNU General Public License v3.0 6 votes vote down vote up
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) 
Example #6
Source File: utils.py    From plasma with GNU General Public License v3.0 6 votes vote down vote up
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) 
Example #7
Source File: space_invaders.py    From sqlalchemy with MIT License 6 votes vote down vote up
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 
Example #8
Source File: curses_tests.py    From CTFCrackTools-V2 with GNU General Public License v3.0 6 votes vote down vote up
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() 
Example #9
Source File: ahuman.py    From gps3 with MIT License 6 votes vote down vote up
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) 
Example #10
Source File: human.py    From gps3 with MIT License 6 votes vote down vote up
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) 
Example #11
Source File: curses_tests.py    From BinderFilter with MIT License 6 votes vote down vote up
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() 
Example #12
Source File: curses_tests.py    From oss-ftp with MIT License 6 votes vote down vote up
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() 
Example #13
Source File: wallet.py    From bitcoind-ncurses with MIT License 6 votes vote down vote up
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() 
Example #14
Source File: wallet.py    From bitcoind-ncurses with MIT License 6 votes vote down vote up
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() 
Example #15
Source File: curses_tests.py    From gcblue with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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() 
Example #16
Source File: footer.py    From bitcoind-ncurses with MIT License 6 votes vote down vote up
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() 
Example #17
Source File: peers.py    From bitcoind-ncurses with MIT License 6 votes vote down vote up
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() 
Example #18
Source File: forks.py    From bitcoind-ncurses with MIT License 6 votes vote down vote up
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() 
Example #19
Source File: cursesgui.py    From ham2mon with GNU General Public License v3.0 6 votes vote down vote up
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 
Example #20
Source File: curses_tests.py    From ironpython3 with Apache License 2.0 6 votes vote down vote up
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() 
Example #21
Source File: curses_tests.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 6 votes vote down vote up
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() 
Example #22
Source File: curses_tests.py    From Fluid-Designer with GNU General Public License v3.0 6 votes vote down vote up
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() 
Example #23
Source File: tui.py    From wifiphisher with GNU General Public License v3.0 6 votes vote down vote up
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 
Example #24
Source File: zktop.py    From python-scripts with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, height, width, server_count):
        BaseUI.__init__(self, curses.newwin(1, width, 0, 0))
        self.session_counts = [0 for i in range(server_count)]
        self.node_counts = [0 for i in range(server_count)]
        self.zxids = [0 for i in range(server_count)] 
Example #25
Source File: textpad.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def test_editbox(stdscr):
        ncols, nlines = 9, 4
        uly, ulx = 15, 20
        stdscr.addstr(uly-2, ulx, "Use Ctrl-G to end editing.")
        win = curses.newwin(nlines, ncols, uly, ulx)
        rectangle(stdscr, uly-1, ulx-1, uly + nlines, ulx + ncols)
        stdscr.refresh()
        return Textbox(win).edit() 
Example #26
Source File: textpad.py    From Imogen with MIT License 5 votes vote down vote up
def test_editbox(stdscr):
        ncols, nlines = 9, 4
        uly, ulx = 15, 20
        stdscr.addstr(uly-2, ulx, "Use Ctrl-G to end editing.")
        win = curses.newwin(nlines, ncols, uly, ulx)
        rectangle(stdscr, uly-1, ulx-1, uly + nlines, ulx + ncols)
        stdscr.refresh()
        return Textbox(win).edit() 
Example #27
Source File: cursesgui.py    From ham2mon with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, screen):
        self.screen = screen

        # Set default values
        self.center_freq = 146E6
        self.samp_rate = 2E6
        self.freq_entry = 'None'
        self.gain_db = 0
        self.if_gain_db = 16
        self.bb_gain_db = 16
        self.squelch_db = -60
        self.volume_db = 0
        self.type_demod = 0
        self.record = True
        self.lockout_file_name = ""
        self.priority_file_name = ""

        # Create a window object in the bottom half of the screen
        # Make it about 1/3 the screen width
        # Place on right side and to the left of the border
        screen_dims = screen.getmaxyx()
        height = int(screen_dims[0]/2.0)-2
        width = int(screen_dims[1]/2.0)-2
        self.win = curses.newwin(height, width, height + 3,
                                 int(screen_dims[1]-width-1))
        self.dims = self.win.getmaxyx() 
Example #28
Source File: textpad.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def test_editbox(stdscr):
        ncols, nlines = 9, 4
        uly, ulx = 15, 20
        stdscr.addstr(uly-2, ulx, "Use Ctrl-G to end editing.")
        win = curses.newwin(nlines, ncols, uly, ulx)
        rectangle(stdscr, uly-1, ulx-1, uly + nlines, ulx + ncols)
        stdscr.refresh()
        return Textbox(win).edit() 
Example #29
Source File: cli.py    From SecureChat with MIT License 5 votes vote down vote up
def __init__(self):
        """
        Initialize the command-line interface.
        """
        self.stdscr = curses.initscr()
        self.client = None
        self.max_y, self.max_x = self.stdscr.getmaxyx()
        self.chat_container = curses.newwin(self.max_y - 2, self.max_x, 1, 0)
        self.chat_win = self.chat_container.subwin(self.max_y - 3, self.max_x - 4, 2, 2)
        self.prompt_win = curses.newwin(1, self.max_x, self.max_y - 1, 0)
        self.setup() 
Example #30
Source File: cursesgui.py    From ham2mon with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, screen):
        self.screen = screen

        # Create a window object in the bottom half of the screen
        # Make it about 1/3 the screen width
        # Place on left side and to the right of the border
        screen_dims = screen.getmaxyx()
        height = int(screen_dims[0]/2.0)-2
        width = int(screen_dims[1]/3.0)-1
        self.win = curses.newwin(height, width, height + 3, 1)
        self.dims = self.win.getmaxyx()