本文整理汇总了Python中curses.COLS属性的典型用法代码示例。如果您正苦于以下问题:Python curses.COLS属性的具体用法?Python curses.COLS怎么用?Python curses.COLS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类curses
的用法示例。
在下文中一共展示了curses.COLS属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: curses_input
# 需要导入模块: import curses [as 别名]
# 或者: from curses import COLS [as 别名]
def curses_input(self, stdscr, row, col, prompt_string, ascii_mode=False):
"""
Get an input string with curses.
Row and col are the start position ot the prompt_string.
"""
curses.echo()
stdscr.addstr(row, col, str(prompt_string), curses.A_REVERSE)
stdscr.addstr(row + 1, col, " " * (curses.COLS - 1))
stdscr.refresh()
input_val = ""
while len(input_val) <= 0:
if ascii_mode:
input_val = chr(stdscr.getch())
break
else:
input_val = stdscr.getstr(row + 1, col, 20)
return input_val
示例2: __init__
# 需要导入模块: import curses [as 别名]
# 或者: from curses import COLS [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, '')
示例3: on_output
# 需要导入模块: import curses [as 别名]
# 或者: from curses import COLS [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: main
# 需要导入模块: import curses [as 别名]
# 或者: from curses import COLS [as 别名]
def main(stdscr):
# Clear screen and hide cursor
stdscr.clear()
curses.curs_set(0)
# Get system infos
macEth0, macWlan0 = getMAC('eth0'), getMAC('wlan0')
ipEth0, ipWlan0 = getIPAddress('eth0'), getIPAddress('wlan0')
# Add title and footer
exittxt = 'Press "q" to exit'
title = '**** System Info ****'
stdscr.addstr(0, int((curses.COLS - len(title)) / 2), title)
stdscr.addstr(22, int((curses.COLS - len(exittxt)) / 2), exittxt)
stdscr.refresh()
netwin = curses.newwin(4, curses.COLS - 6, 12, 3)
netwin.erase()
netwin.border()
eth0info = "eth0 IP: %s - MAC: %s" % (ipEth0, macEth0)
wlan0info = 'wlan0 IP: %s - MAC: %s' % (ipWlan0, macWlan0)
netwin.addstr(1, 2, eth0info)
netwin.addstr(2, 2, wlan0info)
netwin.refresh()
eth0info = "- eth0\nIP: %s\nMAC: %s\n" % (ipEth0, macEth0)
wlan0info = '- wlan0\nIP: %s\nMAC: %s' % (ipWlan0, macWlan0)
sysInfo(eth0info, wlan0info)
c = stdscr.getch()
if c == ord('q'):
exit();
示例5: __init__
# 需要导入模块: import curses [as 别名]
# 或者: from curses import COLS [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 COLS [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 COLS [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 COLS [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: welcome
# 需要导入模块: import curses [as 别名]
# 或者: from curses import COLS [as 别名]
def welcome(self):
"""Displays a welcome message."""
if not self.curses:
if not self.test:
print('Welcome to Google Py Music!')
return
try:
self.main.addstr(
5, int(crs.COLS / 2) - 13, 'Welcome to Google Py Music!'
)
self.main.refresh()
except: # If this errors for some reason, just don't display anything.
pass
示例10: from_current_screen
# 需要导入模块: import curses [as 别名]
# 或者: from curses import COLS [as 别名]
def from_current_screen(cls) -> 'Margin':
return cls(curses.LINES, curses.COLS)
示例11: _curses_update_lines_cols
# 需要导入模块: import curses [as 别名]
# 或者: from curses import COLS [as 别名]
def _curses_update_lines_cols(self):
curses.LINES = self.screen.height
curses.COLS = self.screen.width
示例12: _show
# 需要导入模块: import curses [as 别名]
# 或者: from curses import COLS [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)
示例13: _show
# 需要导入模块: import curses [as 别名]
# 或者: from curses import COLS [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)
示例14: __init__
# 需要导入模块: import curses [as 别名]
# 或者: from curses import COLS [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)