本文整理汇总了Python中curses.textpad.Textbox.gather方法的典型用法代码示例。如果您正苦于以下问题:Python Textbox.gather方法的具体用法?Python Textbox.gather怎么用?Python Textbox.gather使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类curses.textpad.Textbox
的用法示例。
在下文中一共展示了Textbox.gather方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from curses.textpad import Textbox [as 别名]
# 或者: from curses.textpad.Textbox import gather [as 别名]
def main(stdscr):
curses.noecho()
curses.cbreak()
stdscr.keypad(1)
rT = threading.Thread(target=receiving, args=("RecvThread", s))
rT.start()
put = curses.newwin(4, 66, 20, 0)
put.border(0)
put.addstr(1, 1, nick+' >> ')
put.addstr(3, 1, 'Enter to send------------------------------------------q to exit')
put.refresh()
boxbox = curses.newwin(1, 51, 21, 14)
boxbox.refresh()
box = Textbox(boxbox)
message = ''
while message != 'q ':
box.edit()
message = str(box.gather())
if message != '':
s.sendto(nick + " >> " + message, server)
boxbox.clear()
time.sleep(0.2)
s.sendto('3 '+nick, server)
示例2: draw_edit_box
# 需要导入模块: from curses.textpad import Textbox [as 别名]
# 或者: from curses.textpad.Textbox import gather [as 别名]
def draw_edit_box(menu_man, win_man, build_opts):
## BUGGY (resize + too small windows not handled properly)
win_man.resize_wins("edit_mode")
win_man.refresh_all()
curses.curs_set(1)
# Add title of the box
win_man._field_win.bkgd(" ", curses.color_pair(5))
win_man._field_win.addstr(0, 0, menu_man.get_verbose_cur_field(), curses.color_pair(5))
win_man._field_win.chgat(0, 0, -1, curses.color_pair(1))
# Create the window that will holds the text
(YMAX, XMAX) = win_man._field_win.getmaxyx()
(YBEG, XBEG) = win_man._field_win.getparyx()
text_win = curses.newwin(YMAX, XMAX, YBEG + 6, XBEG + 5)
text_win.bkgd(" ", curses.color_pair(5))
text_win.addstr(0, 0, build_opts[menu_man._cur_field], curses.color_pair(5))
# Refresh both windows
win_man._field_win.noutrefresh()
text_win.noutrefresh()
curses.doupdate()
# Create a textbox
box = Textbox(text_win)
box.edit()
build_opts[menu_man._cur_field] = box.gather()[:-2]
del text_win
curses.curs_set(0)
menu_man._cur_field = ""
win_man.resize_wins("menu_mode")
示例3: _main
# 需要导入模块: from curses.textpad import Textbox [as 别名]
# 或者: from curses.textpad.Textbox import gather [as 别名]
def _main(self, stdscr):
try:
# stdscr = curses.initscr()
# Clear screen
stdscr.clear()
# remove the cursor
curses.curs_set(True)
# remove echo from touched keys
# curses.noecho()
self._initPanels(stdscr)
box = Textbox(self.commandInput)
# stdscr.refresh()
th = Thread(target = self.refreshProbes, name = "Probe-Refresh", daemon = True)
th.start()
stdscr.refresh()
while self.isRunning:
stdscr.refresh()
box.edit()
self.doCommand(box.gather())
# commandInput.refresh()
# listen without entering enter
# curses.cbreak())
finally:
self.isRunning = False
th.join()
# let curses handle special keys
stdscr.keypad(True)
stdscr.refresh()
stdscr.getkey()
示例4: _display
# 需要导入模块: from curses.textpad import Textbox [as 别名]
# 或者: from curses.textpad.Textbox import gather [as 别名]
def _display(self, text=None, edit=True):
self._window.refresh()
self._window.border()
text_width = self._width - 2
text_height = self._height - 2
self._window.addstr(0, 1, "[%s]" % "Your answer"[0:text_width - 2])
self._window.addstr(self._height - 1, text_width - 8, "[Ctrl+G]")
#self._window.move(1,1)
self._window.refresh()
if edit:
temporary_edit_window = curses.newwin(text_height, text_width, self._y + 1, self._x + 1)
curses.curs_set(True)
edit_box = Textbox(temporary_edit_window)
edit_box.edit()
curses.curs_set(False)
content = edit_box.gather().strip()
del temporary_edit_window
return content
else:
return None
示例5: main
# 需要导入模块: from curses.textpad import Textbox [as 别名]
# 或者: from curses.textpad.Textbox import gather [as 别名]
def main() :
choice = raw_input("Enter filename : ")
screen = curses.initscr()
curses.noecho()
with open(choice, 'w+') as rf:
filedata = rf.read()
editwin = curses.newwin(20,70, 2,1)
editwin.addstr(1,1,filedata)
rectangle(screen, 1,0, 1+20+1, 1+70+1)
screen.refresh()
box = Textbox(editwin)
# Let the user edit until Ctrl-G is struck.
box.edit()
# Get resulting contents
message = box.gather()
curses.endwin()
with open(choice,'w+') as wf:
wf.write(message)
示例6: main_control
# 需要导入模块: from curses.textpad import Textbox [as 别名]
# 或者: from curses.textpad.Textbox import gather [as 别名]
def main_control(screen, event, inception_level):
if event == ord("Q"):
curses.endwin()
exit(0)
if event == ord("D"):
window_for_done_task(screen)
if event == ord("T"):
window_for_undone_task(screen)
if event == ord("F"):
curses.flash()
if event == ord("A"):
editwin = curses.newwin(1,
screen.getmaxyx()[1]-6,
screen.getmaxyx()[0]-4,
1
)
rectangle(screen,
screen.getmaxyx()[0]-5,
0, screen.getmaxyx()[0]-3,
screen.getmaxyx()[1]-5)
screen.refresh()
box = Textbox(editwin)
# Let the user edit until Ctrl-G is struck.
box.edit()
# Get resulting contents
message = box.gather()
Tache().ajouter_tache(message, datetime.now())
screen.clear()
print_main_screen(screen)
print_taches(screen, Tache().get_tache_undone(), "Taches a faire :")
deal_with_selected(screen, 33, 45, Tache().get_tache_undone(),
window_for_undone_task)
示例7: textbox
# 需要导入模块: from curses.textpad import Textbox [as 别名]
# 或者: from curses.textpad.Textbox import gather [as 别名]
def textbox(nrow, ncol, x, y):
editwin = curses.newwin(nrow,ncol,x,y)
# upleft point x, upleft point y, downright x, downright y
rectangle(scr, x-1, y-1, x + nrow, y + ncol)
scr.refresh()
box = Textbox(editwin)
box.edit()
message = box.gather()
return message
示例8: drawLoginInput
# 需要导入模块: from curses.textpad import Textbox [as 别名]
# 或者: from curses.textpad.Textbox import gather [as 别名]
def drawLoginInput(screen, height, width):
dramaticOutput(screen, height//2, width//2, 'Enter your handle:', 0.05)
handleWindow = curses.newwin(1, 30, height//2+1, width//2 - 16)
handleBox = Textbox(handleWindow)
handleBox.edit()
handle = handleBox.gather()
screen.clear()
dramaticOutput(screen, height//2, width//2, 'Logging you in as ' + handle + '...', 0.05)
time.sleep(1)
return handle
示例9: textbox
# 需要导入模块: from curses.textpad import Textbox [as 别名]
# 或者: from curses.textpad.Textbox import gather [as 别名]
def textbox(screen):
screen.addstr(0, 0, "Enter IM message: (hit Ctrl-G to send)", curses.A_REVERSE)
editwin = curses.newwin(5, 30, 2, 1)
rectangle(screen, 1, 0, 1+5+1, 1+30+1)
screen.refresh()
box = Textbox(editwin)
box.edit()
message = box.gather()
示例10: main
# 需要导入模块: from curses.textpad import Textbox [as 别名]
# 或者: from curses.textpad.Textbox import gather [as 别名]
def main(stdscr):
stdscr = curses.initscr()
stdscr.clear()
stdscr.addstr(0, 0, "JukeBox - v.0.1 'dancing Saci'")
editwin = curses.newwin(5,30, 2,1)
rectangle(stdscr, 1,0,1+5+1, 1+30+1)
stdscr.refresh()
box = Textbox(editwin)
box.edit()
message = box.gather()
示例11: inputwnd
# 需要导入模块: from curses.textpad import Textbox [as 别名]
# 或者: from curses.textpad.Textbox import gather [as 别名]
def inputwnd(stdscr, msg = None, pos_y = None, pos_x = 2, size_y = 1, size_x = 30):
tempscr = tempfile.TemporaryFile()
stdscr.putwin(tempscr)
if pos_y is None:
pos_y = curses.LINES - 5
if msg is not None and (len(msg) + 2 > size_x):
size_x = len(msg) + 2
inputWnd = curses.newwin(size_y, size_x, pos_y, pos_x)
rectangle(stdscr, pos_y - 1, pos_x - 1, pos_y + size_y, pos_x + size_x)
if msg is not None:
stdscr.addstr(pos_y - 1, pos_x, " %s " % msg)
stdscr.refresh()
box = Textbox(inputWnd)
box.edit()
boxtext = box.gather()[:len(box.gather()) - 1]
tempscr.seek(0)
stdscr = curses.getwin(tempscr)
stdscr.refresh()
return boxtext
示例12: main
# 需要导入模块: from curses.textpad import Textbox [as 别名]
# 或者: from curses.textpad.Textbox import gather [as 别名]
def main(stdscr):
stdscr.addstr(0, 0, "Enter IM message: (hit Ctrl-G to send)")
editwin = curses.newwin(30,30, 30, 30)
rectangle(stdscr, 20, 20, 1+5+1, 1+30+1)
stdscr.refresh()
box = Textbox(editwin)
# Let the user edit until Ctrl-G is struck.
box.edit()
# Get resulting contents
message = box.gather()
示例13: main
# 需要导入模块: from curses.textpad import Textbox [as 别名]
# 或者: from curses.textpad.Textbox import gather [as 别名]
def main():
stdscr = curses.initscr()
begin_x = 2
begin_y = 2
height = 8
width = 54
window = curses.newwin(height, width, begin_y, begin_x)
window.addstr(0, 0, "Please type what you heard:")
rectangle(window, 1, 0, 7, 50)
text_box = Textbox(window)
text_box.edit(on_key)
message = text_box.gather()
window.addstr(0, 40, message)
示例14: main
# 需要导入模块: from curses.textpad import Textbox [as 别名]
# 或者: from curses.textpad.Textbox import gather [as 别名]
def main(stdscr):
lines, cols = curses.getmaxyx()
stdscr.addstr(1, 1, "Enter IM message: (hit Ctrl-G to send)")
stdscr.border()
editwin = curses.newwin(5,30, 3,2)
rectangle(stdscr, 2,1, 1+5+1, 1+30+1)
stdscr.refresh()
box = Textbox(editwin)
# Let the user edit until Ctrl-G is struck.
box.edit()
# Get resulting contents
message = box.gather()
示例15: client
# 需要导入模块: from curses.textpad import Textbox [as 别名]
# 或者: from curses.textpad.Textbox import gather [as 别名]
def client(address, send_win):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(address)
payload = (sock,)
Thread(target=listen_for_updates, args=payload).start()
title_buffer_win.addstr(0, 0, STATUS_CONSTANTS[1] + address[0], curses.A_STANDOUT)
while True:
box = Textbox(send_win)
box.edit()
message = box.gather()
message = bytes(message.encode('utf-8'))
sock.sendall(message)
send_win = curses.newwin(1, TERMINAL_SIZE.columns, TERMINAL_SIZE.lines - 1, 0)
update_status(STATUS_CONSTANTS[0])
sock.shutdown(socket.SHUT_RD)
sock.close()