本文整理匯總了Python中curses.textpad方法的典型用法代碼示例。如果您正苦於以下問題:Python curses.textpad方法的具體用法?Python curses.textpad怎麽用?Python curses.textpad使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類curses
的用法示例。
在下文中一共展示了curses.textpad方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: search
# 需要導入模塊: import curses [as 別名]
# 或者: from curses import textpad [as 別名]
def search(self):
"""Open search window, get input and set the search string."""
if self.init_search is not None:
return
scr2 = curses.newwin(3, self.max_x, self.max_y - 3, 0)
scr3 = scr2.derwin(1, self.max_x - 12, 1, 9)
scr2.box()
scr2.move(1, 1)
addstr(scr2, "Search: ")
scr2.refresh()
curses.curs_set(1)
self._search_win_open = 3
self.textpad = Textbox(scr3, insert_mode=True)
self.search_str = self.textpad.edit(self._search_validator)
self.search_str = self.search_str.lower().strip()
try:
curses.curs_set(0)
except _curses.error:
pass
if self.search_str:
self.init_search = None
self._search_win_open = 0
示例2: _search_validator
# 需要導入模塊: import curses [as 別名]
# 或者: from curses import textpad [as 別名]
def _search_validator(self, ch):
"""Fix Enter and backspace for textbox.
Used as an aux function for the textpad.edit method
"""
if ch == curses.ascii.NL: # Enter
return curses.ascii.BEL
elif ch == 127: # Backspace
self.search_str = self.textpad.gather().strip().lower()[:-1]
return 8
else:
if 0 < ch < 256:
c = chr(ch)
if c in string.printable:
res = self.textpad.gather().strip().lower()
self.search_str = res + chr(ch)
self.search_results(look_in_cur=True)
self.display()
return ch
示例3: edit_popup
# 需要導入模塊: import curses [as 別名]
# 或者: from curses import textpad [as 別名]
def edit_popup (stdscr, title, s):
my, mx = stdscr.getmaxyx()
ww = mx * 9 / 10
wh = 3
wox = mx / 2 - ww/2
woy = my / 2 - wh/2
win = curses.newwin(wh, ww, woy, wox)
win.box()
win.addstr(0, 3, title)
win.refresh()
swin = win.derwin (1, ww-4, 1, 2)
tb = curses.textpad.Textbox(swin, insert_mode=True)
swin.insstr (0, 0, tex_encode(s))
swin.refresh()
s = tex_decode(tb.edit())
return s.rstrip()
示例4: __init__
# 需要導入模塊: import curses [as 別名]
# 或者: from curses import textpad [as 別名]
def __init__(self, dlg, posy, posx, length):
self.dlg = dlg
self.win = dlg.win.derwin(1, length, posy, posx)
self.win.keypad(1)
self.box = curses.textpad.Textbox(self.win, insert_mode=True)
self.value = ""
self.result = None
self.editing = False
示例5: test2
# 需要導入模塊: import curses [as 別名]
# 或者: from curses import textpad [as 別名]
def test2():
def main(stdscr):
begin_x = 20
begin_y = 7
height = 5
width = 40
win = curses.newwin(height, width, begin_y, begin_x)
tb = curses.textpad.Textbox(win)
text = tb.edit()
curses.addstr(4,1,text.encode('utf_8'))
time.sleep(10)
nc.wrapper(main)
示例6: get_window_contents
# 需要導入模塊: import curses [as 別名]
# 或者: from curses import textpad [as 別名]
def get_window_contents():
"""Dump the contents of the current curses window."""
tbox = curses.textpad.Textbox(window)
tbox.stripspaces = False
w_str = tbox.gather()
return w_str
示例7: init
# 需要導入模塊: import curses [as 別名]
# 或者: from curses import textpad [as 別名]
def init(stdscr, profile):
cfg_video = getattr(settings, '%s_video' % (profile,))
cfg_telem = getattr(settings, '%s_mavlink' % (profile,))
cfg_tunnel = getattr(settings, '%s_tunnel' % (profile,))
height, width = stdscr.getmaxyx()
height -= 1
w1h = height // 3
w1w = width
w2h = height // 3
w2w = width
w3h = height - w1h - w2h
w3w = width
status_win1 = stdscr.subpad(w1h - 2, w1w - 2, 1, 1)
status_win2 = stdscr.subpad(w2h - 2, w2w - 2, w1h + 1, 1)
status_win3 = stdscr.subpad(w3h - 2, w3w - 2, w1h + w2h + 1, 1)
curses.textpad.rectangle(stdscr, 0, 0, w1h - 1, w1w - 1)
curses.textpad.rectangle(stdscr, w1h, 0, w1h + w2h - 1, w2w - 1)
curses.textpad.rectangle(stdscr, w1h + w2h, 0, w1h + w2h + w3h - 1, w3w - 1)
stdscr.addstr(0, 3, '[video]')
stdscr.addstr(w1h, 3, '[telem]')
stdscr.addstr(w1h + w2h, 3, '[tunnel]')
stdscr.refresh()
for i in (status_win1, status_win2, status_win3):
i.idlok(1)
i.scrollok(1)
if cfg_video.stats_port is not None:
reactor.connectTCP('127.0.0.1', cfg_video.stats_port, AntennaStatClientFactory(status_win1, cfg_video.peer.startswith('listen:')))
else:
status_win1.addstr(0, 0, '[statistics disabled]', curses.A_REVERSE)
status_win1.refresh()
if cfg_telem.stats_port is not None:
reactor.connectTCP('127.0.0.1', cfg_telem.stats_port, AntennaStatClientFactory(status_win2, True))
else:
status_win2.addstr(0, 0, '[statistics disabled]', curses.A_REVERSE)
status_win2.refresh()
if cfg_tunnel.stats_port is not None:
reactor.connectTCP('127.0.0.1', cfg_tunnel.stats_port, AntennaStatClientFactory(status_win3, True))
else:
status_win3.addstr(0, 0, '[statistics disabled]', curses.A_REVERSE)
status_win3.refresh()