python类newwin()的实例源码

textpad.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 88 收藏 0 点赞 0 评论 0
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()
textpad.py 文件源码 项目:sslstrip-hsts-openwrt 作者: adde88 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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()
ascii_qgis.py 文件源码 项目:ascii_qgis 作者: NathanW2 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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)
ascii_qgis.py 文件源码 项目:ascii_qgis 作者: NathanW2 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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)"
ascii_qgis.py 文件源码 项目:ascii_qgis 作者: NathanW2 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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)"
ascii_qgis.py 文件源码 项目:ascii_qgis 作者: NathanW2 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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()
ascii_qgis.py 文件源码 项目:ascii_qgis 作者: NathanW2 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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 = []
terminal_core.py 文件源码 项目:keras_npi 作者: mokemokechicken 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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()
gui.py 文件源码 项目:Music-Scraper 作者: srivatsan-ramesh 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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()
yate_console.py 文件源码 项目:YATE 作者: GarethNelson 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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))
user_input.py 文件源码 项目:pystocker 作者: coffeeandscripts 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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
DSwin.py 文件源码 项目:Otop 作者: fcbarclo 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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) )
DSwin.py 文件源码 项目:Otop 作者: fcbarclo 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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) )
DSwin.py 文件源码 项目:Otop 作者: fcbarclo 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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) )
DSwin.py 文件源码 项目:Otop 作者: fcbarclo 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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) )
DSwin.py 文件源码 项目:Otop 作者: fcbarclo 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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) )
DSwin.py 文件源码 项目:Otop 作者: fcbarclo 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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) )
DSwin.py 文件源码 项目:Otop 作者: fcbarclo 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
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) )
DSwin.py 文件源码 项目:Otop 作者: fcbarclo 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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)
alarm.py 文件源码 项目:Utils 作者: disconsis 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
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


问题


面经


文章

微信
公众号

扫码关注公众号