本文整理匯總了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)