本文整理汇总了Python中curses.LINES属性的典型用法代码示例。如果您正苦于以下问题:Python curses.LINES属性的具体用法?Python curses.LINES怎么用?Python curses.LINES使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类curses
的用法示例。
在下文中一共展示了curses.LINES属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import curses [as 别名]
# 或者: from curses import LINES [as 别名]
def __init__(self, rows=16, cols=100 ):
self.FONTS_SUPPORTED = False
self.rows = rows
self.cols = cols
self.stdscr = curses.initscr()
self.curx = 0
self.cury = 0
if (curses.LINES < rows+1) or (curses.COLS < cols+1):
raise RuntimeError(u"Screen too small. Increase size to at least ({0}, {1})".format(rows+1, cols+1))
# Set up parent class. Note. This must occur after display has been
# initialized as the parent class may attempt to load custom fonts
super(lcd_curses, self).__init__(rows,cols,1)
locale.setlocale(locale.LC_ALL, '')
示例2: get_input
# 需要导入模块: import curses [as 别名]
# 或者: from curses import LINES [as 别名]
def get_input(self, ascii_char=False):
"""Get an input from the user."""
if not self.debug or self.compat_debug:
if ascii_char:
return getch()
else:
if not sys.stdin.isatty():
return input('')
else:
return input('?: ')
else:
return self.curses_input(self.stdscr, curses.LINES - 3, 2, '?: ', ascii_char)
示例3: on_output
# 需要导入模块: import curses [as 别名]
# 或者: from curses import LINES [as 别名]
def on_output(self, value):
value = str(value)
self.outputs_left -= 1
# maximum output reached, we quit the prog
if self.outputs_left == 0:
raise DotsExit
# no printing mode
if self.silent:
return
if not self.debug:
print(value, end='')
sys.stdout.flush()
elif self.compat_debug:
# we add the ouput to the buffer
self.compat_logging_buffer += value
# and we keep the maximum number of line to compat_logging_buffer_lines
self.compat_logging_buffer = '\n'.join(
self.compat_logging_buffer.split('\n')[-self.compat_logging_buffer_lines:])
else:
# add the output string to the pad
self.logging_pad.addstr(self.logging_loc, self.logging_x, str(value))
self.logging_pad.refresh(self.logging_loc - min(self.logging_loc, curses.LINES -
self.debug_lines - 1),
0, self.debug_lines, 0, curses.LINES - 1, curses.COLS - 1)
# FIXME: This should count the number of newlines instead
if str(value).endswith('\n'):
self.logging_loc += 1
self.logging_x = 1
else:
self.logging_x += len(value)
示例4: __init__
# 需要导入模块: import curses [as 别名]
# 或者: from curses import LINES [as 别名]
def __init__(self):
self.too_small = False
self.init_curses()
self.top = 0
self.bottom = len(CLIENTS)+1
self.max_lines = curses.LINES-len(LOGO)
self.hori_len = 0
self.EXIT_FLAG = 0
示例5: __init__
# 需要导入模块: import curses [as 别名]
# 或者: from curses import LINES [as 别名]
def __init__(self, stdscr, pages, titles):
self.top = 0
self.position = self.top
self.pages = pages
self.page_titles = titles
self.cur_page = 0
self.window = stdscr
self.height = curses.LINES - 1
self.width = curses.COLS - 1
self.bottom = len(self.cur_page.items)
curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_WHITE)
示例6: populate
# 需要导入模块: import curses [as 别名]
# 或者: from curses import LINES [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)
示例7: test_resize_term
# 需要导入模块: import curses [as 别名]
# 或者: from curses import LINES [as 别名]
def test_resize_term(stdscr):
if hasattr(curses, 'resizeterm'):
lines, cols = curses.LINES, curses.COLS
curses.resizeterm(lines - 1, cols + 1)
if curses.LINES != lines - 1 or curses.COLS != cols + 1:
raise RuntimeError, "Expected resizeterm to update LINES and COLS"
示例8: get_windows
# 需要导入模块: import curses [as 别名]
# 或者: from curses import LINES [as 别名]
def get_windows():
"""
Initialize the curses windows.
Returns: Curses windows.
"""
main = crs.initscr() # For the bulk of output.
main.resize(crs.LINES - 3, crs.COLS)
inbar = crs.newwin(1, crs.COLS, crs.LINES - 1, 0) # For user input.
infobar = crs.newwin(1, crs.COLS, crs.LINES - 2, 0) # For 'now playing'.
outbar = crs.newwin(1, crs.COLS, crs.LINES - 3, 0) # For notices.
return main, inbar, infobar, outbar
示例9: from_current_screen
# 需要导入模块: import curses [as 别名]
# 或者: from curses import LINES [as 别名]
def from_current_screen(cls) -> 'Margin':
return cls(curses.LINES, curses.COLS)
示例10: _curses_update_lines_cols
# 需要导入模块: import curses [as 别名]
# 或者: from curses import LINES [as 别名]
def _curses_update_lines_cols(self):
curses.LINES = self.screen.height
curses.COLS = self.screen.width
示例11: _show
# 需要导入模块: import curses [as 别名]
# 或者: from curses import LINES [as 别名]
def _show(self, stdscr):
win = curses.newwin(self._height, self._width,
(curses.LINES - self._height) // 2,
(curses.COLS - self._width) // 2)
win.keypad(1)
win.border()
textbox = win.derwin(self._height - 1, self._width - 3, 1, 2)
textbox.addstr(0, 0, self._message)
return self._loop(win)
示例12: _show
# 需要导入模块: import curses [as 别名]
# 或者: from curses import LINES [as 别名]
def _show(self, stdscr):
# Set a reasonable size for our input box.
lines, cols = curses.LINES - 10, curses.COLS - 40
y_begin, x_begin = (curses.LINES - lines) // 2, (curses.COLS - cols) // 2
editwin = curses.newwin(lines, cols, y_begin, x_begin)
editwin.addstr(0, 1, "{}: (hit Ctrl-G to submit)".format(self._message))
rectangle(editwin, 1, 0, lines-2, cols-1)
editwin.refresh()
inputwin = curses.newwin(lines-4, cols-2, y_begin+2, x_begin+1)
box = Textbox(inputwin)
self._load(box, self._content)
return self._edit(box)
示例13: __init__
# 需要导入模块: import curses [as 别名]
# 或者: from curses import LINES [as 别名]
def __init__(self, items):
""" Initialize the screen window
Attributes
window: A full curses screen window
width: The width of `window`
height: The height of `window`
max_lines: Maximum visible line count for `result_window`
top: Available top line position for current page (used on scrolling)
bottom: Available bottom line position for whole pages (as length of items)
current: Current highlighted line number (as window cursor)
page: Total page count which being changed corresponding to result of a query (starts from 0)
┌--------------------------------------┐
|1. Item |
|--------------------------------------| <- top = 1
|2. Item |
|3. Item |
|4./Item///////////////////////////////| <- current = 3
|5. Item |
|6. Item |
|7. Item |
|8. Item | <- max_lines = 7
|--------------------------------------|
|9. Item |
|10. Item | <- bottom = 10
| |
| | <- page = 1 (0 and 1)
└--------------------------------------┘
Returns
None
"""
self.window = None
self.width = 0
self.height = 0
self.init_curses()
self.items = items
self.max_lines = curses.LINES
self.top = 0
self.bottom = len(self.items)
self.current = 0
self.page = self.bottom // self.max_lines
示例14: __init__
# 需要导入模块: import curses [as 别名]
# 或者: from curses import LINES [as 别名]
def __init__(self, awesome_title, awesome_blocks, initial_query=''):
""" Initialize the screen window
Args
awesome_title: Awesome topic title
awesome_blocks: A list of formatted awesome content
It has a set of names and web links for crawled awesome content
initial_query: An optional initial query given from shell
Attributes
window: A full curses screen window
result_window: A window for showing the results
search_window: A window for search bar
y: Current y coordinates
width: The width of `window`
height: The height of `window`
awesome_title: Awesome title
awesome_blocks: It holds given `awesome_blocks` argument
matched_blocks: A list of found awesome content
max_lines: Maximum visible line count for `result_window`
top: Available top line position for current page (used on scrolling)
bottom: Available bottom line position for whole pages (as length of found lines)
current: Current highlighted line number
page: Total page count which being changed dynamically corresponding to result of a query
query: Query string for searching the awesome content
Returns
None
"""
self.window = None
self.result_window = None
self.search_window = None
self.y = 0
self.width = 0
self.height = 0
self.awesome_title = awesome_title
self.awesome_blocks = awesome_blocks
self.matched_blocks = awesome_blocks
self.init_curses()
self.init_layout()
self.max_lines = curses.LINES - 4
self.top = 0
self.bottom = self.max_lines
self.current = 0
self.page = self.bottom // self.max_lines
self.write_string(initial_query)