本文整理汇总了Python中curses.html方法的典型用法代码示例。如果您正苦于以下问题:Python curses.html方法的具体用法?Python curses.html怎么用?Python curses.html使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类curses
的用法示例。
在下文中一共展示了curses.html方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cbreak
# 需要导入模块: import curses [as 别名]
# 或者: from curses import html [as 别名]
def cbreak(self):
"""Return a context manager that enters 'cbreak' mode: disabling line
buffering of keyboard input, making characters typed by the user
immediately available to the program. Also referred to as 'rare'
mode, this is the opposite of 'cooked' mode, the default for most
shells.
In 'cbreak' mode, echo of input is also disabled: the application must
explicitly print any input received, if they so wish.
More information can be found in the manual page for curses.h,
http://www.openbsd.org/cgi-bin/man.cgi?query=cbreak
The python manual for curses,
http://docs.python.org/2/library/curses.html
Note also that setcbreak sets VMIN = 1 and VTIME = 0,
http://www.unixwiz.net/techtips/termios-vmin-vtime.html
"""
if self.keyboard_fd is not None:
# save current terminal mode,
save_mode = termios.tcgetattr(self.keyboard_fd)
tty.setcbreak(self.keyboard_fd, termios.TCSANOW)
try:
yield
finally:
# restore prior mode,
termios.tcsetattr(self.keyboard_fd,
termios.TCSAFLUSH,
save_mode)
else:
yield
示例2: draw
# 需要导入模块: import curses [as 别名]
# 或者: from curses import html [as 别名]
def draw(self, target):
""" Draw internal data to curses window """
self.window.clear()
self.window.addstr(0, 0, self.map)
# FIXME: position to be defined in map config?
row = self.corners[2]-6
items_to_show = 5
for lat, lon, char, desc, attrs, color in self.data:
# to make this work almost everywhere. see http://docs.python.org/2/library/curses.html
if desc:
desc = desc.encode(self.encoding, 'ignore')
if items_to_show <= 0:
break
char_x, char_y = self.latlon_to_coords(lat, lon)
if self.colors and color:
attrs |= curses.color_pair(self.colors[color])
self.window.addstr(char_y, char_x, char, attrs)
if desc:
det_show = "%s %s" % (char, desc)
else:
det_show = None
if det_show is not None:
try:
self.window.addstr(row, 1, det_show, attrs)
row += 1
items_to_show -= 1
except StandardError:
# FIXME: check window size before addstr()
break
self.window.overwrite(target)
self.window.leaveok(1)