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

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

项目: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)
项目: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)