当前位置: 首页>>代码示例>>Python>>正文


Python curses.newpad方法代码示例

本文整理汇总了Python中curses.newpad方法的典型用法代码示例。如果您正苦于以下问题:Python curses.newpad方法的具体用法?Python curses.newpad怎么用?Python curses.newpad使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在curses的用法示例。


在下文中一共展示了curses.newpad方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newpad [as 别名]
def __init__(self, enable=True):
        self.enable = enable
        if not self.enable:
            return
        self.logger = logging.getLogger('trader-logger')
        self.stdscr = curses.initscr()
        self.pad = curses.newpad(23, 120)
        self.order_pad = curses.newpad(10, 120)
        self.timestamp = ""
        self.last_order_update = 0
        curses.start_color()
        curses.noecho()
        curses.cbreak()
        curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_GREEN)
        curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_RED)
        self.stdscr.keypad(1)
        self.pad.addstr(1, 0, "Waiting for a trade...") 
开发者ID:mcardillo55,项目名称:cbpro-trader,代码行数:19,代码来源:cursesDisplay.py

示例2: _create_screen

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newpad [as 别名]
def _create_screen(self):
    
        try:
            if self.lines_were_auto_set: self.lines = None
            if self.cols_were_auto_set: self.columns = None
        except: pass

        
        if not self.lines: 
            self.lines = self._max_physical()[0]+1
            self.lines_were_auto_set = True
        if not self.columns: 
            self.columns = self._max_physical()[1]+1
            self.cols_were_auto_set = True

        if self.min_l > self.lines:
            self.lines = self.min_l

        if self.min_c > self.columns:
            self.columns = self.min_c

        #self.area = curses.newpad(self.lines, self.columns)
        self.curses_pad = curses.newpad(self.lines, self.columns)
        #self.max_y, self.max_x = self.lines, self.columns
        self.max_y, self.max_x = self.curses_pad.getmaxyx() 
开发者ID:hexway,项目名称:apple_bleee,代码行数:27,代码来源:proto_fm_screen_area.py

示例3: make_text_box

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newpad [as 别名]
def make_text_box(self, boxes):
        self.boxes = boxes
        self.pad = curses.newpad(self.PAD_WIDTH, self.PAD_HEIGHT)

        self.pad.box()
        height = 1
        for num, text in enumerate(boxes, 1):
            box = self.pad.derwin(
                self.BOX_HEIGHT, self.BOX_WIDTH, height, self.PAD_WIDTH//2 - self.BOX_WIDTH//2)
            box.box()
            if len(text) > 37:
                text = text[:36] + "..."
            box.addstr(1, 0, "{}. {}".format(num, text))
            yield box
            height += self.BOX_HEIGHT
        self.max_height = height 
开发者ID:yihong0618,项目名称:gaycore,代码行数:18,代码来源:gcore_box.py

示例4: create_text_win

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newpad [as 别名]
def create_text_win(self, length, header):
        # calculate dimensions
        w = max(self.cols - 4, 60)
        h = self.rows - 2
        x = int(self.cols / 2 - w / 2)
        y = 1

        win = curses.newwin(h,w,y,x)
        win.box()
        win.addstr(1,2, '{:^{l}}'.format(header, l=(w-3)))
        
        self.stdscr.clear()
        self.stdscr.refresh()
        win.refresh()
        pad = curses.newpad(length,1000)
        pad.keypad(True)
        
        return win, pad 
开发者ID:dsanson,项目名称:termpdf.py,代码行数:20,代码来源:termpdf.py

示例5: __init__

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newpad [as 别名]
def __init__(self, stdscr, height, width, top, left):
        # Dimensions and position of region in stdscr which will contain the pad
        self.region_height = height
        self.region_width = width
        self.region_top = top
        self.region_left = left

        # How many statuses fit on one page (excluding border, at 3 lines per status)
        self.page_size = (height - 2) // 3

        # Initially, size the pad to the dimensions of the region, will be
        # increased later to accomodate statuses
        self.pad = curses.newpad(10, width)
        self.pad.box()

        # Make curses interpret escape sequences for getch (why is this off by default?)
        self.pad.keypad(True)

        self.scroll_pos = 0 
开发者ID:ihabunek,项目名称:toot,代码行数:21,代码来源:app.py

示例6: __init__

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newpad [as 别名]
def __init__(self, stdscr, player, timeout):
		self.stdscr = stdscr
		self.height, self.width = stdscr.getmaxyx()
		self.player = player
		self.scroll_pad = curses.newpad(self.player.track.length + 2,
					self.player.track.width + 2)
		self.current_pos = 0
		self.pad_offset = 1
		self.text_padding = 5
		self.keys = Key()

		curses.use_default_colors()
		self.stdscr.timeout(timeout)
		self.set_up() 
开发者ID:Jugran,项目名称:lyrics-in-terminal,代码行数:16,代码来源:window.py

示例7: _screen_new_output_pad

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newpad [as 别名]
def _screen_new_output_pad(self, rows, cols):
    """Generate a new pad on the screen.

    Args:
      rows: (int) Number of rows the pad will have: not limited to screen size.
      cols: (int) Number of columns the pad will have: not limited to screen
        size.

    Returns:
      A curses textpad object.
    """

    return curses.newpad(rows, cols) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:15,代码来源:curses_ui.py

示例8: _main_loop

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newpad [as 别名]
def _main_loop(self, scr):
        if scr is not None:
            CursesMenu.stdscr = scr
        self.screen = curses.newpad(len(self.items) + 6, CursesMenu.stdscr.getmaxyx()[1])
        self._set_up_colors()
        curses.curs_set(0)
        CursesMenu.stdscr.refresh()
        self.draw()
        CursesMenu.currently_active_menu = self
        self._running.set()
        while self._running.wait() is not False and not self.should_exit:
            self.process_user_input() 
开发者ID:pmbarrett314,项目名称:curses-menu,代码行数:14,代码来源:curses_menu.py

示例9: init_scr

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newpad [as 别名]
def init_scr(self):
        self.stdscr = curses.initscr()
        curses.noecho()
        curses.curs_set(0)

        self.stdscr_size = self.stdscr.getmaxyx()
        self.task_total = count_file_linenum(self.config.seedfile)

        self.pgsscr_size = (self.config.proc_num + 2, 40)
        self.pgsscr = curses.newpad(*self.pgsscr_size)
        self.cntscr_size = (4, 40)
        self.cntscr = curses.newpad(*self.cntscr_size)
        self.optscr_size = (18, 80)
        self.optscr = curses.newpad(*self.optscr_size) 
开发者ID:RickGray,项目名称:cyberbot,代码行数:16,代码来源:cyberbot.py

示例10: populate

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newpad [as 别名]
def populate(self, results):
        if not self.results == None:
          del self.results
        self.results = curses.newpad(max(len(results), curses.LINES - 1), curses.COLS//2)
        self.results.clear()
        for i in range(curses.LINES - SEARCHBAR_OFFSET):
          self.results.insch(i, curses.COLS//2 - 2, curses.ACS_VLINE)
        i = 0
        for result in results:
          # print(result)
          self.results.addstr(i, 0, result.name)
          if (not result.images == None) and (self.w3m_enabled):
            try:
                images_array = ast.literal_eval(result.images) 
                temp_file = util.RDBDIR + 'tmp'
                #os.remove(temp_file)
                # print(result.images[0])
                request.urlretrieve(images_array[0], temp_file)
                self.draw_image(temp_file, curses.COLS - curses.COLS/2, SEARCHBAR_OFFSET, curses.COLS/2, curses.LINES - SEARCHBAR_OFFSET)
                if self.first_pic:
                  self.first_pic = False
            except Exception as e:
                # Who cares? it's just a picture.
                self.end()
                print(str(e))
                pass
          i += 1

        self.results.noutrefresh(0, 0, SEARCHBAR_OFFSET, 0, curses.LINES-1, curses.COLS-1) 
开发者ID:install-logos,项目名称:ricedb,代码行数:31,代码来源:render.py

示例11: _main_loop

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newpad [as 别名]
def _main_loop(self, scr):
		if scr is not None:
			CursesMenu.stdscr = scr
			
		height = 7
		screen_rows, screen_cols = CursesMenu.stdscr.getmaxyx()
		for index, item in enumerate( self.items ):
			end = -1
			indent = 0
			textLen = len( item.text )
			itemText = item.show( index )
			while end < textLen - 1:
				height += 1
				start = end + 1
				end = min(start + screen_cols - 15 - indent, textLen )
				if end < textLen:
					for x in range(15):
						if itemText[end] in '- ,;':
							break
						end = min( end + 1, textLen - 1 )
				indent = 16
		self.screen = curses.newpad(height, CursesMenu.stdscr.getmaxyx()[1])
		self._set_up_colors()
		curses.curs_set(0)
		CursesMenu.stdscr.refresh()
		self.draw()
		CursesMenu.currently_active_menu = self
		self._running.set()
		while self._running.wait() is not False and not self.should_exit:
			self.process_user_input() 
开发者ID:mholgatem,项目名称:GPIOnext,代码行数:32,代码来源:curses_menu.py

示例12: meta

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newpad [as 别名]
def meta(stdscr, ebook):
    rows, cols = stdscr.getmaxyx()
    hi, wi = rows - 4, cols - 4
    Y, X = 2, 2
    meta = curses.newwin(hi, wi, Y, X)
    if COLORSUPPORT:
        meta.bkgd(stdscr.getbkgd())

    meta.box()
    meta.keypad(True)
    meta.addstr(1,2, "Metadata")
    meta.addstr(2,2, "--------")
    key_meta = 0

    mdata = []
    for i in ebook.get_meta():
        data = re.sub("<[^>]*>", "", i[1])
        data = re.sub("\t", "", data)
        mdata += textwrap.wrap(i[0].upper() + ": " + data, wi - 6)
    src_lines = mdata
    totlines = len(src_lines)

    pad = curses.newpad(totlines, wi - 2 )
    if COLORSUPPORT:
        pad.bkgd(stdscr.getbkgd())

    pad.keypad(True)
    for n, i in enumerate(src_lines):
        pad.addstr(n, 0, i)
    y = 0
    meta.refresh()
    pad.refresh(y,0, Y+4,X+4, rows - 5, cols - 6)

    padhi = rows - 5 - Y - 4 + 1

    while key_meta not in META|QUIT:
        if key_meta in SCROLL_UP and y > 0:
            y -= 1
        elif key_meta in SCROLL_DOWN and y < totlines - hi + 6:
            y += 1
        elif key_meta in PAGE_UP:
            y = pgup(y, padhi)
        elif key_meta in PAGE_DOWN:
            y = pgdn(y, totlines, padhi)
        elif key_meta in CH_HOME:
            y = 0
        elif key_meta in CH_END:
            y = pgend(totlines, padhi)
        elif key_meta in {curses.KEY_RESIZE}|HELP|TOC:
            return key_meta
        pad.refresh(y,0, 6,5, rows - 5, cols - 5)
        key_meta = meta.getch()

    meta.clear()
    meta.refresh()
    return 
开发者ID:wustho,项目名称:epr,代码行数:58,代码来源:epr.py

示例13: help

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newpad [as 别名]
def help(stdscr):
    rows, cols = stdscr.getmaxyx()
    hi, wi = rows - 4, cols - 4
    Y, X = 2, 2
    help = curses.newwin(hi, wi, Y, X)
    if COLORSUPPORT:
        help.bkgd(stdscr.getbkgd())

    help.box()
    help.keypad(True)
    help.addstr(1,2, "Help")
    help.addstr(2,2, "----")
    key_help = 0

    src = re.search("Key Bind(\n|.)*", __doc__).group()
    src_lines = src.splitlines()
    totlines = len(src_lines)

    pad = curses.newpad(totlines, wi - 2 )
    if COLORSUPPORT:
        pad.bkgd(stdscr.getbkgd())

    pad.keypad(True)
    for n, i in enumerate(src_lines):
        pad.addstr(n, 0, i)
    y = 0
    help.refresh()
    pad.refresh(y,0, Y+4,X+4, rows - 5, cols - 6)

    padhi = rows - 5 - Y - 4 + 1

    while key_help not in HELP|QUIT:
        if key_help in SCROLL_UP and y > 0:
            y -= 1
        elif key_help in SCROLL_DOWN and y < totlines - hi + 6:
            y += 1
        elif key_help in PAGE_UP:
            y = pgup(y, padhi)
        elif key_help in PAGE_DOWN:
            y = pgdn(y, totlines, padhi)
        elif key_help in CH_HOME:
            y = 0
        elif key_help in CH_END:
            y = pgend(totlines, padhi)
        elif key_help in {curses.KEY_RESIZE}|META|TOC:
            return key_help
        pad.refresh(y,0, 6,5, rows - 5, cols - 5)
        key_help = help.getch()

    help.clear()
    help.refresh()
    return 
开发者ID:wustho,项目名称:epr,代码行数:54,代码来源:epr.py

示例14: __init__

# 需要导入模块: import curses [as 别名]
# 或者: from curses import newpad [as 别名]
def __init__(self, env, ticks, silent, debug, compat_debug, debug_lines, autostep_debug, output_limit):
        """

        :param dots.environment.Env env: The env of the interpreter
        :param int ticks: The max number of ticks for the program
        :param bool silent: True to turn off all outputs
        :param bool debug: True to show the execution of the program
        :param bool compat_debug: True to show the debug with only builtin functions
        :param int debug_lines: The number of lines to show the debug
        :param float autostep_debug: The timebetween automatic ticks. 0 disables the auto ticks.
        :param int output_limit: The max number of outputs for the program
        """
        super(DefaultIOCallbacks, self).__init__(env)

        # if it is zero or false, we don't want to stop
        self.ticks_left = ticks or float('inf')
        self.outputs_left = output_limit or float('inf')

        self.silent = silent
        self.debug = debug
        self.compat_debug = compat_debug
        self.debug_lines = debug_lines
        self.debug_cols = terminalsize.get_terminal_size()[0] - 1
        self.autostep_debug = autostep_debug

        self.compat_logging_buffer = ''
        self.compat_logging_buffer_lines = terminal_lines - debug_lines - 1

        self.first_tick = True

        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()

            # hides the cursor
            curses.curs_set(False)

            # defining the two main parts of the screen: the view of the program
            self.win_program = curses.newwin(self.debug_lines, curses.COLS, 0, 0)
            # and pad for the output of the prog
            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) 
开发者ID:aaronjanse,项目名称:asciidots,代码行数:60,代码来源:__main__.py


注:本文中的curses.newpad方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。