我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用curses.newwin()。
def __init__(self, file): self.file = file self.scr = curses.initscr() self.scr.border() self.scr_height, self.scr_width = self.scr.getmaxyx() self.text_win = curses.newwin(self.scr_height - 1, self.scr_width, 1, 0) self.file_text = file.content if self.file_text != None: self.text_win.addstr(self.file_text) curses.noecho() #curses.start_color() #curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_GREEN) if self.file.exists: self.start_editor() else: curses.endwin() gc.error('An error occurred while editing this file.')
def __init__(self, username): os.environ.setdefault('ESCDELAY', '25') # shorten esc delay self.username = username # set up IRC self.channel = "##HTP" # set up curses self.scr = curses.initscr() self.disconnect = False curses.start_color() self.scr_height, self.scr_width = self.scr.getmaxyx() self.chatbar = curses.newwin(5, self.scr_height - 1, 5, 10) self.msg_text = '' self.logfile = '../data/irc.txt' self.log_text = [] # curses color config curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_GREEN) # start the client try: curses.wrapper(self.start_loop()) except Exception as e: self.scr.addstr(2, 0, str(e), curses.A_REVERSE) # client game loop
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()
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()
def top(args): scr = curses.initscr() #scr.start_color() curses.noecho() curses.cbreak() hx, wm = scr.getmaxyx() scr.keypad(True) try: header = curses.newwin(HEADER_SIZE, wm, 0, 0) body = curses.newwin(BODY_SIZE, wm, HEADER_SIZE, 0) while True: draw_header(header) draw_body(body) draw_footer(scr) sleep(0.2) except KeyboardInterrupt: curses.nocbreak() scr.keypad(False) curses.echo() curses.endwin()
def _wrapped_run(self, stdscr): self.left_width = 60 self.right_width = curses.COLS - self.left_width # Setup windows self.top = curses.newwin(2, curses.COLS, 0, 0) self.left = curses.newpad(curses.LINES * 2, self.left_width) self.right = curses.newwin(curses.LINES - 4, self.right_width, 2, self.left_width) self.bottom = curses.newwin(2, curses.COLS, curses.LINES - 2, 0) Color.setup_palette() # Load some data and redraw self.fetch_next() self.selected = 0 self.full_redraw() self.loop()
def __init__(self, parent, x, y, w=None, h=None): self._children = [] self._parent = parent self._x = x self._y = y self._h = h self._w = w self._vcenter, self._hcenter = False, False self.set_size(w, h) ax, ay = self.get_screen_coords(0, 0) self._wnd = curses.newwin(self._h, self._w, ay, ax) if parent is not None: parent._children.append(self)
def __init__(self, stdscr, label="", x=0, y=0, width=10, height=1): self.default_color = 'white-black' self.stdscr = stdscr self.label = label self.x, self.y = x, y self.width, self.height = width, height self.borderbox = curses.newwin(height + 2, width + 2, y - 1, x - 1) self.textinpt = curses.newwin(height, width, y, x) self.textinpt.bkgd(' ', colors.get_colorpair(self.default_color)) self.textinpt.keypad(1) self.refresh()
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()
def enter_edit_mode(self, value=None): if self.items[self.position]['field'] == 'Comments': editwin = curses.newwin(10, 60, self.position+2, 27) rectangle(self.window, self.position + 1, 26, self.position + 12, 26 + 61) else: editwin = curses.newwin(1, 30, self.position+2, 27) editwin.attron(curses.color_pair(2)) curses.curs_set(1) if value: box = _Textbox(editwin, True, text=value) else: box = _Textbox(editwin, True, text=self.items[self.position]['value']) _Textbox.stripspaces = True self.window.refresh() while True: edit_field = box.edit() if not edit_field is None: result = self.validate(edit_field.strip()) if result: self.navigate(1) break else: break curses.curs_set(0) self.window.clear()
def sub_selection_dialog(self, pos): """ Draw a `Selection Dialog` on screen used to make configurations. :param pos: Index of selected item in `Configure Setting` frame. :type pos: int .. warning:: The value of `pos` MUST NOT be `None`. :return: A **WindowObject** which represents the selection dialog. :rtype: WindowObject """ i_len = len(self.settings[pos][2]) # Draw Shadow shadow = curses.newwin(i_len + 2, 18, 13 - i_len / 2, 31) shadow.bkgd(' ', curses.color_pair(8)) shadow.refresh() # Draw Subwindow screen = curses.newwin(i_len + 2, 18, 12 - i_len / 2, 30) screen.box() screen.bkgd(' ', curses.color_pair(1)) screen.keypad(1) # Set local variable normal = curses.A_NORMAL # Title of Subwindow screen.addstr(0, 3, self.settings[pos][0].center(12), normal) return screen
def __init__( self, x, y, width, height, fg=curses.COLOR_BLACK, bg=curses.COLOR_WHITE ): self.win = curses.newwin( height, width, y, x ) self.dimensions = ( x, y, width, height ) """ if curses.has_colors(): color = 1 curses.init_pair( color, fg, bg ) self.win.bkgdset( ord(' '), curses.color_pair(color) ) else: self.win.bkgdset( ord(' '), curses.A_BOLD ) """ self.erase() self.setScrolling() self.win.noutrefresh()
def __init__(self, screen): self.screen = screen (max_y, max_x) = self.screen.getmaxyx() self.window = curses.newwin(5, max_x, self.row, 0) self.status = '' self.banner = Banner(self.window, self.banner_prefix) # Widgets self.widgets = { 'X+': Button(self.window, 'X+', 3, 6), 'X-': Button(self.window, 'X-', 3, 0), 'Y+': Button(self.window, 'Y+', 2, 3), 'Y-': Button(self.window, 'Y-', 4, 3), 'Z+': Button(self.window, 'Z+', 2, 11), 'Z-': Button(self.window, 'Z-', 4, 11), 'jog': NumberLabel(self.window, 1, 6, 0.001), 'MPosX': NumberLabel(self.window, 2, 21), 'MPosY': NumberLabel(self.window, 3, 21), 'MPosZ': NumberLabel(self.window, 4, 21), 'WPosX': NumberLabel(self.window, 2, 31), 'WPosY': NumberLabel(self.window, 3, 31), 'WPosZ': NumberLabel(self.window, 4, 31), 'feed_rate': Label(self.window, 2, 44, len=20, text='?', prefix='Feed Rate: '), 'spindle': Label(self.window, 3, 44, len=20, text='?', prefix='Spindle: '), } self.render() self.refresh()
def init_window(self, row, height): self.window = curses.newwin(height, self.screen.getmaxyx()[1], row, 0) self.banner = Banner(self.window, self.title)
def __init__(self, title, w, h, y, x): self.win = curses.newwin(h, w, y, x) self.win.border(0) self.win.addstr(0, 1, title)
def __init__(self, mainwindow, game_menu): self.main = mainwindow self.game = game_menu size = mainwindow.getmaxyx() self.win = curses.newwin(size[0]-5, PREVIEW_WIDTH, 4, GAME_WIDTH + SYSTEM_WIDTH + 2) self.last_game_loaded = None
def __init__(self): self.swin = curses.newwin(4, 59, 0, 0) self.inp = curses.newwin(1, 55, 2, 2) self.text = textpad.Textbox(self.inp, insert_mode=False) self.history_point = 0 self.search_history = collections.deque(maxlen=100)
def __init__(self, mainwindow): self.main = mainwindow size = mainwindow.getmaxyx() self.syswin = curses.newwin(size[0]-5, SYSTEM_WIDTH, 4, 0) self.gameswin = curses.newwin(size[0]-5, GAME_WIDTH, 4, SYSTEM_WIDTH) self.offset = 0 self.pos = 0 self.search_pos = 0
def __init__(self, ticks, silent, debug, compat_debug, debug_lines, autostep_debug, head): super().__init__() self.ticks = ticks self.silent = silent self.debug = debug self.compat_debug = compat_debug self.debug_lines = debug_lines self.autostep_debug = autostep_debug self.head = head self.tick_number = 0 self.output_count = 0 if self.debug and not self.compat_debug: self.logging_loc = 0 self.logging_x = 1 self.stdscr = curses.initscr() curses.start_color() curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLACK) curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_BLACK) curses.init_pair(3, curses.COLOR_YELLOW, curses.COLOR_BLACK) curses.init_pair(4, curses.COLOR_BLUE, curses.COLOR_BLACK) curses.noecho() curses.curs_set(False) self.win_program = curses.newwin(self.debug_lines, curses.COLS - 1, 0, 0) self.logging_pad = curses.newpad(1000, curses.COLS - 1) def signal_handler(signal, frame): self.on_finish() sys.exit(0) signal.signal(signal.SIGINT, signal_handler)
def newlinebox(h, w, y, x, title=None, line=True, opts=None): wb = curses.newwin(2, w, y-1, x) wb.keypad(True) if line: wb.addstr(0, 0, e(HORLINE)*w, 0 if opts is None else opts) if title is not None: wb.addstr(0, 2, e(title), 0 if opts is None else opts) pn = curses.panel.new_panel(wb) wb.refresh() win = curses.newwin(h, w, y, x) win.keypad(True) panel = curses.panel.new_panel(win) return win, panel, wb, pn
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
def __init__(self): y, x = scr.getmaxyx() self.infowin = curses.newwin(y / 2, x / 2, y / 4, x / 4) self.infopanel = curses.panel.new_panel(self.infowin) self.infowin.keypad(1)
def __init__(self): y, x = scr.getmaxyx() self.win = curses.newwin(y - TOPBORDER, 30, BOTTOMBORDER, 0) self.win.keypad(1) self.items = [] self.title = "Layers (F5)"
def __init__(self): y, x = scr.getmaxyx() self.mapwin = curses.newwin(y - TOPBORDER, x - 30, BOTTOMBORDER, 30) self.mapwin.keypad(1) self.settings = None self.title = "Map (F6)"
def __init__(self): y, x = scr.getmaxyx() self.modeline = curses.newwin(1, x, y - 1, 0) self.modeline.bkgd(curses.color_pair(6)) self.modeline.refresh()
def __init__(self): y, x = scr.getmaxyx() self.edit = curses.newwin(1, x, y - 2, 0) self.status = curses.newwin(1, x, y - 3, 0) self.pad = Textbox(self.edit, insert_mode=True) self.lastcmd = []
def init_window(self, width, height): curses.curs_set(0) border_win = curses.newwin(height + 2, width + 2, self.W_TOP, self.W_LEFT) # h, w, y, x border_win.box() self.stdscr.refresh() border_win.refresh() self.main_window = curses.newwin(height, width, self.W_TOP + 1, self.W_LEFT + 1) self.main_window.refresh() self.main_window.timeout(1) self.info_window = curses.newwin(self.INFO_WINDOW_HEIGHT, self.INFO_WINDOW_WIDTH, self.W_TOP + 1, self.W_LEFT + width + 2) self.log_window = curses.newwin(self.LOG_WINDOW_HEIGHT, self.LOG_WINDOW_WIDTH, self.W_TOP + max(height, self.INFO_WINDOW_HEIGHT) + 5, self.W_LEFT) self.log_window.refresh()
def init_display(): """ Inits the display GUI """ if not GUI.gui_stopped: curses.noecho() curses.cbreak() curses.start_color() GUI.screen.keypad(1) curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_CYAN) GUI.high_light_text = curses.color_pair(1) GUI.normal_text = curses.A_NORMAL curses.curs_set(0) GUI.refresh_values() GUI.position = 1 GUI.page = 1 GUI.box = curses.newwin(GUI.max_row + 3, curses.COLS, 0, 0) GUI.box.addstr(1, 1, GUI.status, GUI.high_light_text) GUI.add_bottom_menus() GUI.screen.refresh() GUI.box.refresh()
def init_voxel_display(self): self.voxel_win = curses.newwin(self.h-4,self.w-2,self.y+3,self.x+2) self.voxel_panel = curses.panel.new_panel(self.voxel_win) self.voxel_panel.bottom() self.voxel_panel.hide() for x in xrange(1,self.w-3,1): for y in xrange(1,self.h-4): eventlet.greenthread.sleep(0) self.voxel_win.addstr(y,x,'!',curses.color_pair(VOXEL_COLOR_PAIR+yateproto.YATE_VOXEL_UNKNOWN))
def input_n(cursor, scr_bottom, max_stock_range, stock_list, scr_dim): stock_input = None curses.start_color() curses.init_pair(5,curses.COLOR_WHITE,curses.COLOR_BLUE) stock_win = curses.newwin(1, 10, scr_dim[0]-1, 0) stock_win.bkgd(curses.color_pair(5)) stock_box = textpad.Textbox(stock_win) stock_win.refresh() scr_bottom.addstr(0, curses.COLS-20, " [Enter]Save/Exit") scr_bottom.refresh() stock_input = stock_box.edit() stock_input = stock_input.upper() if str(stock_input) != "" and str(stock_input) not in stock_list: stocks.add_stock_code(str(stock_input)) total_stocks = len(stock_list) + 1 if total_stocks > scr_dim[0] - 6: cursor[1] = total_stocks cursor[2] = max_stock_range else: cursor[1] = max_stock_range + 1 cursor[2] = cursor[1] elif str(stock_input) or ((str(stock_input)[0:(len(str(stock_input)) - 2)] and str(stock_input)[len(str(stock_input))])) in stock_list: total_stocks = len(stock_list) stock_pos = stock_list.index(str(stock_input)) + 1 cursor[1] = stock_pos if total_stocks > max_stock_range: cursor[2] = 1 else: cursor[2] = cursor[1] return cursor
def WinPrintOtopVersion(self): try: versionmsg = "Otop 0.5.5 ["+str(self.scrsize[0] )+","+str(self.scrsize[1] )+"]" ypos = self.scrsize[0]-2 xpos = self.scrsize[1]-len(versionmsg)-2 self.winotopversion = curses.newwin(1,len(versionmsg)+1,ypos,xpos) self.winotopversion.addstr(0,0,versionmsg,self.REDONBLACK) self.winotopversion.refresh() except: winotopversion = -1 self.WinPrintError("WinPrintOtopVersion Error:"+str(err) )
def WinBanner(self): try: banner = self.DBbanner() self.winbanner = curses.newwin(1,len(banner)+1,1,2) self.winbanner.addstr(0,0,banner,self.REDONBLACK) self.winbanner.refresh() except Exception as err: winb = -1 self.WinPrintError("WinBanner Error:"+str(err) )
def WinConnInfo(self): y = self.WinOtopData[self.ID_PAD_CI][1] x = self.WinOtopData[self.ID_PAD_CI][2] nlines = self.WinOtopData[self.ID_PAD_CI][3] hsize = len(self.Vconndata_head) Ltmp=(self.ID_PAD_CI,y,x,nlines,hsize) self.padrefreshcoord.append(Ltmp) try: self.connIpad = curses.newpad(y+nlines+3,x+hsize+2) self.connIwinbox = curses.newwin( y+nlines+2, hsize+3, y, x) except Exception as err: self.connIpad = -1 self.WinPrintError("WinConnInfo curses Error:"+str(err) ) finally: try: if not self.WinCheckThreadAlive(self.idthconn): self.idthconn = threading.Thread(target=self._WinconninfoshowTH,name='conninfoshowTH') self.idthconn.setDaemon(True) self.thConfig.append((self.ID_PAD_CI,1)) else: self.lockvideo.acquire() self.connIpad.addstr(1,1,self.Vconndata_head,self.CYANONBLACK) self.connIpad.addstr(2,2,"waiting refresh... ",self.GREENONBLACK) self.connIpad.refresh(1,0,y+1,x+1,y+nlines+1,x+hsize) self.lockvideo.release() except Exception as err: self.connIpad = -10 self.WinPrintError("WinConnInfo thrd Error:"+str(err) )
def Windb(self): y = self.WinOtopData[self.ID_PAD_DB][1] x = self.WinOtopData[self.ID_PAD_DB][2] nlines = self.WinOtopData[self.ID_PAD_DB][3] hsize = len(self.Vdbdata_head) Ltmp=(self.ID_PAD_DB,y,x,nlines,hsize) self.padrefreshcoord.append(Ltmp) try: self.dbpad = curses.newpad(y+nlines+3,x+hsize+2) self.dbwinbox = curses.newwin( y+nlines+2, hsize+3, y, x) except Exception as err: self.dbpad =-1 self.WinPrintError("Windb curses Error:"+str(err) ) finally: try: if not self.WinCheckThreadAlive(self.idthdb): self.idthdb = threading.Thread(target=self._WindbshowTH,name='dbshowTH') self.idthdb.setDaemon(True) self.thConfig.append((self.ID_PAD_DB,1)) else: self.lockvideo.acquire() self.dbpad.addstr(1,1,self.Vdbdata_head,self.CYANONBLACK) self.dbpad.addstr(2,2,"waiting refresh... ",self.GREENONBLACK) self.dbpad.refresh(1,0,y+1,x+1,y+nlines+1,x+hsize) self.lockvideo.release() except Exception as err: self.dbpad =-10 self.WinPrintError("Windb thrd Error:"+str(err) )
def Wininst(self): y = self.WinOtopData[self.ID_PAD_INST][1] x = self.WinOtopData[self.ID_PAD_INST][2] nlines = self.WinOtopData[self.ID_PAD_INST][3] hsize = len(self.Vinstdata_head) self.instdata_head = 'Instance info' Ltmp=(self.ID_PAD_INST,y,x,nlines,hsize) self.padrefreshcoord.append(Ltmp) try: self.instpad = curses.newpad(y+nlines+3,x+hsize+2) self.instwinbox = curses.newwin( nlines+3, hsize+3, y, x) except Exception as err: self.instpad =-1 self.WinPrintError("Wininst curses Error:"+str(err) ) finally: try: if not self.WinCheckThreadAlive(self.idthinst): self.idthinst = threading.Thread(target=self._WininstshowTH,name='instshowTH') self.idthinst.setDaemon(True) self.thConfig.append((self.ID_PAD_INST,1)) else: self.lockvideo.acquire() self.instpad.addstr(1,1,self.Vinstdata_head,self.CYANONBLACK) self.instpad.addstr(2,2,"waiting refresh... ",self.GREENONBLACK) self.instpad.refresh(1,0,y+1,x+1,y+nlines+1,x+hsize) self.lockvideo.release() except Exception as err: self.instpad =-10 self.WinPrintError("Wininst thrd Error:"+str(err) )
def Winsess(self): y = self.WinOtopData[self.ID_PAD_SESS][1] x = self.WinOtopData[self.ID_PAD_SESS][2] nlines = self.WinOtopData[self.ID_PAD_SESS][3] hsize = len(self.Vsessdata_head) self.session_head = 'Active sessions (no sys/system)' virtual_v_size = nlines*self.MAX_SESS_ROWS + y + 3 Ltmp=(self.ID_PAD_SESS,y,x,nlines,hsize) self.padrefreshcoord.append(Ltmp) try: self.sesspad = curses.newpad(virtual_v_size,x+hsize+2) self.sesswinbox = curses.newwin( nlines+3, hsize+3, y, x) except Exception as err: self.sesspad =-1 self.WinPrintError("Winsess curses Error:"+str(err) ) finally: try: if not self.WinCheckThreadAlive(self.idthsess): self.idthsess = threading.Thread(target=self._WinsessshowTH,name='sessshowTH') self.idthsess.setDaemon(True) self.thConfig.append((self.ID_PAD_SESS,1)) else: self.lockvideo.acquire() self.sesspad.addstr(1,1,self.Vsessdata_head,self.CYANONBLACK) self.sesspad.addstr(2,2,"waiting refresh... ",self.GREENONBLACK) self.sesspad.refresh(1,0,y+1,x+1,y+nlines+1,x+hsize) self.lockvideo.release() except Exception as err: self.sesspad =-10 self.WinPrintError("Winsess thrd Error:"+str(err) )
def Wintopsql(self): y = self.WinOtopData[self.ID_PAD_TOPSQL][1] x = self.WinOtopData[self.ID_PAD_TOPSQL][2] nlines = self.WinOtopData[self.ID_PAD_TOPSQL][3] hsize = len(self.Vtopsql_head) self.topsql_head = 'Top 5 sql in last awr snapshot (no sys/system)' Ltmp=(self.ID_PAD_TOPSQL,y,x,nlines,hsize) self.padrefreshcoord.append(Ltmp) try: self.topsqlpad = curses.newpad(y+nlines+3,x+hsize+2) self.topsqlwinbox = curses.newwin( nlines+3, hsize+3, y, x) except Exception as err: self.topsqlpad =-1 self.WinPrintError("Wintopsql curses Error:"+str(err) ) finally: try: if not self.WinCheckThreadAlive(self.idthtopsql): self.idthtopsql = threading.Thread(target=self._WinTopSqlshowTH,name='topsqlTH') self.idthtopsql.setDaemon(True) self.thConfig.append((self.ID_PAD_TOPSQL,1)) else: self.lockvideo.acquire() self.topsqlpad.addstr(1,1,self.Vtopsql_head,self.CYANONBLACK) self.topsqlpad.addstr(2,2,"waiting refresh..." ,self.GREENONBLACK) self.topsqlpad.refresh(1,0,y+1,x+1,y+nlines+1,x+hsize) self.lockvideo.release() except Exception as err: self.tbspad =-10 self.WinPrintError("Wintopsql thrd Error:"+str(err) )
def Winthset(self): self.lockvideo.acquire() y = self.Ypos_start_sensor x = self.Xpos_start_sensor head = "" voidhead = "" # make led display for k in range( 0, len(self.WinOtopData)): head += self.WinOtopData[k][5] voidhead += "_" if k<len(self.WinOtopData)-1: head += "|" voidhead += "|" hsize = len(head) try: winthr = curses.newwin( 4, hsize+2, y, x) winthr.box() winthr.addstr(1,1,head) winthr.addstr(2,1,voidhead) except Exception as err: self.winthr = -1 self.WinPrintError("Winthset Error:"+str(err) ) self.lockvideo.release() return(winthr)
def center(stdscr, string, font, color_pair, oldwin): out = toilet(string, font) out_cols = max([len(line) for line in out]) out_lines = len(out) win = curses.newwin(out_lines, out_cols, (curses.LINES - out_lines)//2, (curses.COLS - out_cols)//2) if oldwin is not None: oldwin.clear() oldwin.refresh() for li, line in enumerate(out): win.addstr(li, 0, line, color_pair) win.refresh() return win