我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用curses.resizeterm()。
def get_screen(self): self.screen = 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) if self.x == 0: starty, startx = self.screen.getmaxyx() self.x = startx self.y = starty resize = curses.is_term_resized(self.y, self.x) # Action in loop if resize is True: if resize is True: y, x = self.screen.getmaxyx() self.screen.clear() curses.resizeterm(self.y, self.x) self.screen.refresh() self.show_header() return self.screen
def resize(self): """Handle window resizing.""" if curses.is_term_resized(self.max_win_size_y, self.max_win_size_x): self.win_init() self.box_init() self.text = [self._text_wrap(i) for i in self.text] curses.resizeterm(self.max_win_size_y, self.max_win_size_x)
def update_size(self): # get terminal size size = terminalsize.get_terminal_size() self.x = max(size[0], 10) self.y = max(size[1], 25) # update intendations curses.resizeterm(self.y, self.x) self.startcol = int(float(self.x) / 5) self.indented_startcol = max(self.startcol - 3, 0) self.update_space() self.screen.clear() self.screen.refresh()
def resize(self): y, x = self.screen.window.getmaxyx() self.screen.clear() curses.resizeterm(y, x)
def handleScreenResize(self, window): #app.log.debug('handleScreenResize -----------------------') if sys.platform == 'darwin': # Some terminals seem to resize the terminal and others leave it # to the application to resize the curses terminal. rows, cols = app.curses_util.terminalSize() curses.resizeterm(rows, cols) self.layout() window.controller.onChange() self.render() self.top, self.left = app.window.mainCursesWindow.getyx() self.rows, self.cols = app.window.mainCursesWindow.getmaxyx() self.layout()
def WinCgetch(self): kp = -1 while kp==-1: kp = self.VWscreen.getch() ScrResized = curses.is_term_resized(self.scrsize[0],self.scrsize[1]) if ScrResized: try: y,x = self.VWscreen.getmaxyx() minY = self.ScreenMinY minX = self.ScreenMinX bestY = self.ScreenFullY bestX = self.ScreenFullX if (y<minY) | (x<minX): # check resized size self.VWscreen.clear() self.VWscreen.refresh() curses.resizeterm(self.scrsize[0],self.scrsize[1]) # reset to original size self.VWscreen.clear() self.VWscreen.refresh() curses.flash() self.WinPrintError("Screen size not valid. ") time.sleep(1) self.PRG_EXIT_SCR_SIZE = 1 curses.ungetch(27) # push ESC key to main loop: exit from program else: # set new size if (y>= bestY) and (x>=bestX): self.ScreenFullSize = 1 else: self.ScreenFullSize = 0 self.VWscreen.clear() curses.resizeterm(y, x) self.scrsize = [] self.scrsize = (y,x) self.WinRefreshScr() except Exception as err: self.WinPrintError("Error resizing screen... "+str(err)+ " " ) return(kp)