Python curses 模块,resizeterm() 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用curses.resizeterm()

项目:webnuke    作者:bugbound    | 项目源码 | 文件源码
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
项目:notex    作者:adiultra    | 项目源码 | 文件源码
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)
项目:WxNeteaseMusic    作者:yaphone    | 项目源码 | 文件源码
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()
项目:wpm    作者:cslarsen    | 项目源码 | 文件源码
def resize(self):
        y, x = self.screen.window.getmaxyx()
        self.screen.clear()
        curses.resizeterm(y, x)
项目:RasWxNeteaseMusic    作者:yaphone    | 项目源码 | 文件源码
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()
项目:NEmusicbox    作者:PyCN    | 项目源码 | 文件源码
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()
项目:ci_edit    作者:google    | 项目源码 | 文件源码
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()
项目:Otop    作者:fcbarclo    | 项目源码 | 文件源码
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)