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)
def feditwin(editwin_loc): """ Create a window to write message in. Parameters ---------- editwin_loc: list the edit window localisation. Returns ------- :class:curses._CursesWindow The edit window. :class:curses.Textbox The textbox to write text in. """ n_line = editwin_loc[2] - editwin_loc[0] or 1 n_col = editwin_loc[3] - editwin_loc[1] y = editwin_loc[0] x = editwin_loc[1] editwin = newwin(n_line, n_col, y, x) editwin.keypad(True) box = Textbox(editwin) box.edit() return editwin, box
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)
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
def __edit_box(self, title, input_msg, placeholder="", size=5, is_attachment=False): '''Function to show edit text box on screen''' curses.curs_set(1) self.__set_default_screen(title) # self.__stdscr.addstr(0, 0, input_msg) _, w = self.__stdscr.getmaxyx() number_of_lines = size number_of_columns = w - 3 # create a new window editwin = curses.newwin(number_of_lines, number_of_columns, 2, 1) rectangle(self.__stdscr, 1, 0, 2 + number_of_lines, 2 + number_of_columns) if is_attachment: self.__stdscr.addstr(number_of_lines + 3, 1, "* Use ; to separate multiple filepaths") self.__stdscr.refresh() editwin.insstr(placeholder) # Make this new window a textbox to edit box = Textbox(editwin) # box.stripspaces = True box.edit() self.__set_default_screen(self.__title, isMain=True) curses.curs_set(0) return box.gather()
def send(stdscr, contactId, contactName): draw_window(stdscr, "Briar Linux Client", "Type your message and press Ctrl+G to send") # Centering calculations height, width = stdscr.getmaxyx() z = 18 x, y = int((width // 2) - (z // 2) - z % 2), 3 stdscr.addstr(y - 1, x, "New message for: " + contactName, curses.color_pair(2)) ncols, nlines = 40, 5 uly, ulx = 5, 2 editwin = curses.newwin(nlines, ncols, uly, ulx) rectangle(stdscr, uly - 1, ulx - 1, uly + nlines, ulx + ncols) stdscr.refresh() box = Textbox(editwin) # Let the user edit until Ctrl-G is struck. box.edit() # Get resulting contents message = box.gather() if message != "": url_format = apiURL + "/v1/messages/" + contactId response = requests.post(url_format, headers=auth, json={"text": message}) stdscr.addstr(20, 10, "Message sent") else: stdscr.addstr(20, 10, "Message empty", curses.color_pair(4)) stdscr.refresh() stdscr.getch() messages(stdscr, contactId, contactName)
def input(): editwin = curses.newwin(1, 60, 7, 3) rectangle(screen, 6, 2, 6 + 1 + 1, 2 + 60 + 1) screen.refresh() box = Textbox(editwin) box.edit() return box.gather()
def main(screen): while True: screen.clear() # command help screen.addstr(padding + 14, padding + 0, '* Commands') screen.addstr(padding + 15, padding + 0, 'Ctrl-G or Enter : send request / Ctrl-C : exit') # current resource usage screen.addstr(padding + 0, padding + 0, '* Current Usage of Entries') printResourceBar(screen) # input request screen.addstr(padding + 9, padding + 0, '* Enter the request ') edit_win = curses.newwin(1, BAR_SIZE, 11 + padding, 1 + padding) rectangle(screen, padding + 10, padding + 0, padding + 1 + 10 + 1, padding + 1 + BAR_SIZE + 1) screen.refresh() box = Textbox(edit_win) box.edit() input_text = box.gather() if input_text != '': translateRules(input_text) populateRulesetToDP() # if translation succeed
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")
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()
def draw_menu(stdscr): k = 0 # Clear and refresh the screen for a blank canvas stdscr.clear() stdscr.refresh() height, width = stdscr.getmaxyx() # Start colors in curses curses.start_color() curses.init_pair(1, curses.COLOR_CYAN, curses.COLOR_BLACK) curses.init_pair(2, curses.COLOR_RED, curses.COLOR_BLACK) curses.init_pair(3, curses.COLOR_BLACK, curses.COLOR_WHITE) summoner_name_str = 'Summoner name:' start_x_title = int((width // 2) - (len(summoner_name_str))) stdscr.addstr(0, start_x_title, summoner_name_str, curses.color_pair(3)) stdscr.refresh() editwin = curses.newwin(1, 17, 0, int((width // 2) + 1)) box = Textbox(editwin) # Let the user edit until Ctrl-G is struck. box.edit() # Get resulting contents message = box.gather() while k != ord('q'): stdscr.clear() stdscr.refresh() stdscr.addstr(0, 0, message) # Refresh the screen # Wait for next input k = stdscr.getch()
def user_submit(auth, assignment, stdscr, contents=''): stdscr.clear() stdscr.addstr(0, 0, "Which file to submit: (hit ctrl-g to finish)") editwin = curses.newwin(5, 30, 2, 1) rectangle(stdscr, 1, 0, 1 + 5 + 1, 1 + 30 + 1) stdscr.addstr(1 + 5 + 2, 0, contents) stdscr.refresh() box = Textbox(editwin) box.edit() message = box.gather().rstrip() if message.startswith("!ls"): try: contents = repr(os.listdir(message[4:])) except: contents = '' try: open(message, 'rb').close() except: return user_submit(auth, assignment, stdscr, contents) stdscr.clear() stdscr.addstr( 0, 0, "What should the submission be titled? (hit ctrl-g to finish)") editwin = curses.newwin(5, 30, 2, 1) rectangle(stdscr, 1, 0, 1 + 5 + 1, 1 + 30 + 1) stdscr.refresh() box = Textbox(editwin) box.edit() submit(auth, assignment, message, box.gather().rstrip())
def loadPrintScreen(data): #Screen and actions for loading external files data.stdscr.clear() data.stdscr.addstr(0, 0, "Enter board file name (including '.txt')" +\ " and press 'enter'") boxH,boxW = 1,30 startY, startX = 3,1 editwin = curses.newwin(boxH,boxW, startY,startX) rectULY, rectULX = 2, 0 rectangle(data.stdscr, rectULY, rectULX, rectULY+boxH+1, rectULX+boxW+1) data.stdscr.addstr(rectULY+boxH+2,0, "Max size is %d x %d." % data.boardMax \ + "If loaded board "+\ "is smaller, rows and columns will be added. If too large, rows and"+\ " columns will be removed until max dimensions acheived. If more space is"+\ " needed, quit and resize the console window/reduce font size.") data.stdscr.refresh() box = Textbox(editwin) # Let the user edit until Ctrl-G is struck. box.edit() # Get resulting contents userInput = box.gather() try:#attempt to load user generated board data.lifeBoard = loadBoardState(userInput) data.loadedBoardTitle = userInput data.boardLoaded = True checkBoardSize(data) #fit to size except: #Something went wrong... data.stdscr.addstr(1,0, "Entered board state not found. "\ +"Returning to main menu.", curses.color_pair(1) | curses.A_STANDOUT) curses.beep() data.stdscr.refresh() curses.napms(2000) data.loadScreen = False
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
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)
def edited_text(scr, text, y, x, w=50, prompt="Edit the text then Ctrl-G to exit"): """ Provides the editing capability: Returns the edited (or not) version of text. Editing window begins at (y,x) of the <scr>een, consists of 3 rows and is w+2 characters wide. Text to be edited appears on line y+1 beginning in column x+1 within a 'bordered' window with room for w characters or as many as are in text, which ever is the greater. The <prompt> overwrites the box border in bold. """ # scr. # scr.refresh() if l := len(text) > w: w = l # create the text box with border around the outside tb_border = cur.newwin(3, w + 2, y, x) tb_border.box() # place promt on line above the box tb_border.refresh() scr.addstr(y, x + 2, prompt, cur.A_BOLD) scr.refresh() tb_body = cur.newwin(1, w, y + 1, x + 1) tb = Textbox(tb_body) for ch in text: # insert starting text tb.do_command(ch) tb.edit() # start the editor running, Ctrl-G ends s2 = tb.gather() # fetch the contents scr.clear() # clear the screen # return s2 return s2.strip()
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)
def command(stdscr, repl_y, repl_x): stdscr.addstr(repl_y, 0, ":") editwin = curses.newwin(1, repl_x - 1, repl_y, repl_x + 2) editwin.refresh() stdscr.refresh() box = Textbox(editwin) box.edit() return box.gather()
def testbox(): myscreen.clear() myscreen.border(0) editwin = curses.newwin(5, 30, 2, 1) rectangle(myscreen, 1, 0, 1 + 5 + 1, 1 + 30 + 1) myscreen.refresh() box = Textbox(editwin) box.edit()
def edit_box(): global box, NUM_LINES, NUM_COLS, TOP, LEFT, chosen_option, edit_box_message editwin = curses.newwin(NUM_LINES, NUM_COLS - 1, TOP, LEFT + len(chosen_option) + 2) box = Textbox(editwin) for char in edit_box_message: box.do_command(char) box.edit(navigator)
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
def main(stdscr): curses.init_pair(1, curses.COLOR_RED, curses.COLOR_WHITE) curses.init_pair(2, curses.COLOR_RED, curses.COLOR_BLUE ) #curses.noecho() #curses.curs_set(0) #stdscr.clear() #stdscr.resize(50, 50) #stdscr.border(0) #x=input("...waiting..") #curses.endwin() stdscr.border(0) stdscr.refresh() stdscr_y = curses.LINES - 1 stdscr_x = curses.COLS - 1 drawCoor(stdscr) pad = curses.newpad(20, 20) pad2 = curses.newpad(20, 20) for y in range(0, 19): for x in range(0, 19): pad.addch(y,x, ord('a') + (x*x+y*y) % 26) for y in range(0, 19): for x in range(0, 19): pad2.addch(y,x, ord('-')) pad.border(0) pad2.border(0) pad2.refresh(0,0, 15,5, 65,30) pad.refresh(0,0, 5,15, 30,40) stdscr.refresh() stdscr.addstr(15, 50,"Pretty text", curses.color_pair(2)) stdscr.addstr(10, 50, "Current mode: Typing mode", curses.A_REVERSE) stdscr.addstr(10, 50, "HELLO") stdscr.refresh() stdscr.addstr(50, 50, "Enter IM message: (hit Ctrl-G to send)") rectangle(stdscr, 40,80, 60, 100) stdscr.refresh() ## Let the user edit until Ctrl-G is struck. editwin = curses.newwin(10,10, 50,90) # height, width, begin_y, begin_x stdscr.refresh() box = Textbox(editwin) box.edit()
class EditWidget(Widget): def __init__(self, parent, x, y, w, h, title, default): Widget.__init__(self, parent, x, y, w, h, title) self.default = default self.editor = Textbox(self.win) self.win.addstr(0, 0, default) def key(self, k): if k == ord('\n'): self.editor.edit()
def show_search_screen(stdscr): curses.curs_set(1) stdscr.addstr(1, 2, "Artist name: (Ctrl-G to search)") editwin = curses.newwin(1, 40, 3, 3) rectangle(stdscr, 2, 2, 4, 44) stdscr.refresh() box = Textbox(editwin) box.edit() criteria = box.gather() return criteria
def switch_buffer(self): """ prompts to a buffer, opens it """ prompt = curses.subwin(1, curses.COLS-1, curses.LINES -1, 0) prompt.addstr("BUFFER NAME:") inputbox = Textbox(prompt) inputbox.edit() dest = gather(inputbox) self.open_buffer(dest.split(":")[1])
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()
def main(output): ouput = curses.initscr() field = curses.newwin(2, curses.COLS, curses.LINES - 3, 0) curses.start_color() curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK) curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_YELLOW) output.bkgd(curses.color_pair(1)) field.bkgd(curses.color_pair(2)) box = Textbox(field) box.edit()
async def textbox(handler): """ Handles user input to the textbox. """ while True: win['t'].erase() box = Textbox(win['t']) box.edit() message = box.gather() await handler(message)
def get_filename(self): editwin = curses.newwin(1, 30, 10, 1) rectangle(stdscr, 9, 0, 11, 42) stdscr.refresh() box = Textbox(editwin) # Let the user edit until Ctrl-G is struck. box.edit() return box.gather()
def getText(self, dflt=""): offset = 40 width = 30 self.showGetRectangle() self.textWin.addstr(0,0,dflt) box = Textbox(self.textWin) box.edit() message = box.gather() self.textWin.clear() return message.strip()
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
def inputCommand(self): box = Textbox(self.commandWin) # Let the user edit until Ctrl-G is struck. box.edit() # Get resulting contents message = box.gather() self.commandWin.clear() return message
def main(stdscr): stdscr.addstr(0, 0, "Introduzca mensaje: (Ctrl-G para terminar)") editwin = curses.newwin(5, 30, 2,1) rectangle(stdscr, 1,0, 1 + 5 + 1, 1 + 30 +1) stdscr.refresh() box = Textbox(editwin) box.edit() # Let the user edit until Ctrl-G is struck message = box.gather() # Get resulting contents
def edit(self): self.text_win.clear() try: self.text_win.addstr(self.pages[self.pagenum]) except curses.error: pass textbox = Textbox(self.text_win, insert_mode=True) if not self.istest: textbox.edit() self.pages[self.pagenum] = collect(textbox) curses.flash()
def main(stdscr, Numero_Linhas): stdscr.addstr(0, 0, "Enter IM message: (hit Ctrl-G to send)") editwin = curses.newwin(Numero_Linhas, 30, 2, 1) rectangle(stdscr, 1, 0, 1 + Numero_Linhas + 1, 1 + 30 + 1) stdscr.refresh() box = Textbox(editwin) # Let the user edit until Ctrl-G is struck. box.edit([Control - A, Control - B]) # Get resulting contents message = box.gather() return message
def main(stdscr): curses.init_pair(1, curses.COLOR_RED, curses.COLOR_WHITE) curses.init_pair(2, curses.COLOR_RED, curses.COLOR_BLUE) #curses.noecho() #curses.curs_set(0) #stdscr.clear() #stdscr.resize(50, 50) #stdscr.border(0) #x=input("...waiting..") #curses.endwin() stdscr.border(0) stdscr.refresh() stdscr_y = curses.LINES - 1 stdscr_x = curses.COLS - 1 drawCoor(stdscr) pad = curses.newpad(20, 20) pad2 = curses.newpad(20, 20) for y in range(0, 19): for x in range(0, 19): pad.addch(y, x, ord('a') + (x * x + y * y) % 26) for y in range(0, 19): for x in range(0, 19): pad2.addch(y, x, ord('-')) pad.border(0) pad2.border(0) pad2.refresh(0, 0, 15, 5, 65, 30) pad.refresh(0, 0, 5, 15, 30, 40) stdscr.refresh() stdscr.addstr(15, 50, "Pretty text", curses.color_pair(2)) stdscr.addstr(10, 50, "Current mode: Typing mode", curses.A_REVERSE) stdscr.addstr(10, 50, "HELLO") stdscr.refresh() stdscr.addstr(50, 50, "Enter IM message: (hit Ctrl-G to send)") rectangle(stdscr, 40, 80, 60, 100) stdscr.refresh() ## Let the user edit until Ctrl-G is struck. editwin = curses.newwin(10, 10, 50, 90) # height, width, begin_y, begin_x stdscr.refresh() box = Textbox(editwin) box.edit()
def _textbox(self, prompt): self.foot.erase() self.foot.addstr(0, 0, prompt, curses.A_BOLD) curses.curs_set(1) self.foot.refresh() tb = self.foot.subwin(self.maxy - 1, len(prompt)) box = Textbox(tb) box.edit() curses.curs_set(0) result = box.gather() self.foot.erase() return result
def main(stdscr): stdscr.addstr(0, 0, "Enter IM message :(hit Ctrl-G to send)") 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()
def downloadMp4ByURL(self, stdscr, format): stdscr.addstr(0, 0, "Enter YouTube URL: (hit Ctrl-G to download)") editwin = curses.newwin(1,80, 2,1) rectangle(stdscr, 1,0, 1+1+1, 1+80+1) stdscr.refresh() box = Textbox(editwin) box.edit() url = box.gather() if format == "MP3 DOWNLOAD": Download.mp3Download(url, "test") elif format == "MP4 DOWNLOAD": Download.mp4Download(url, "test")
def name_screen(w, h): print_centered(w, 2, "Enter NAME: (hit ENTER to send)", "top") print_centered(w, h, "To play the game use your arrow keys:", "mid") print_centered(w, h + 2, "<- left | right ->", "mid") editwin = curses.newwin(1, 12, 5, (w // 2) - 6) rectangle(stdscr, 4, w // 2 - 8, 6, w // 2 + 8) stdscr.refresh() box = Textbox(editwin) box.edit() return box.gather()
def main(): stdscr = curses.initscr() stdscr.addstr(0, 0, "Enter IM message: (hit Ctrl-G to send)") editwin = curses.newwin(5,30, 2,1) rectangle(stdscr, 1,0, 1+5+1, 1+30+1) stdscr.refresh() box = Textbox(editwin) # Let the user edit until Ctrl-G is struck. box.edit()
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()
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()
def main(stdscr): stdscr.clear() columns = split_into_columns(stdscr,3) shouldExit = False box = Textbox(columns[0]) rect = rectangle(columns[0],5,5,0,0) while not shouldExit: box.edit() k = stdscr.getkey() if k == "q": shouldExit = True
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)
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()
def insertFile(): global cursor, stdscr, theWorld title = "/\\\\ Set field name //\\" win = curses.newwin(3, theWorld.w - 10, theWorld.h / 2 - 1, 6) win.box() size = win.getmaxyx() win.addstr(0, size[1] / 2 - len(title) / 2, title) win.refresh() win = curses.newwin(1, theWorld.w - 12, theWorld.h / 2, 7) t = Textbox(win) filename = t.edit() f = file(filename[:-1]) x, y = theWorld.player.pos for line in f.readlines(): for letter in line: theWorld.player.gMap.setAscii(x, y, letter) theWorld.player.gMap.setFG(x, y, foreground) theWorld.player.gMap.setBG(x, y, background) theWorld.player.gMap.setWalkable(x, y, walkable) x += 1 x = theWorld.player.pos[0] y += 1
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()
def run_curses(self, win): self.setup_win(win) self.editwin = win.subwin(1, curses.COLS - 1, curses.LINES - 1, 0) editpad = Textbox(self.editwin) while not self.closed: line = editpad.edit() self.editwin.erase() if line: self.send_admin(line)
def main() : screen = curses.initscr() height, width = screen.getmaxyx() curses.noecho() boardwin = curses.newwin(height-2, width-10, 0, 0) stashwin = curses.newwin((height-2)/2, 10, 0, width-10) playerwin = curses.newwin((height-2)/2, 10, (height-2)/2, width-10) msgwin = curses.newwin(1, width, height-2, 0) cmdwin = curses.newwin(1, width-5, height-1, 5) cmdline = Textbox(cmdwin) screen.addstr(height-1, 1, ">>>") screen.refresh() boardwin.box() boardwin.addstr(1, 1, "Board") boardwin.refresh() stashwin.box() stashwin.addstr(1, 1, "Stash") stashwin.refresh() playerwin.box() playerwin.addstr(1, 1, "Players") playerwin.refresh() msgwin.addstr(0, 1, "Enter 'START [Star1] [Star2] [Ship]' to start the game.") msgwin.refresh() players = ["Alpha", "Beta"] run = True while run : cmd = cmdline.edit().split(" ") try : error = eval(cmd[0].lower())(player, cmd[1:]) except Exception : error = "ERROR: Unknown command or invalid arguments" if not "ERROR:" in error : cmdwin.clear() updateBoard(game.getBoard()) updateStash(game.getStash()) updateMsg(error) player = players[players.index(player)-1] else : updateMsg(error) curses.echo() curses.endwin()
def print_ajouter_tache(self): self.screen.addstr(self.max["y"]-6, 1, "Ajouter une tache :") editwin = curses.newwin(1, self.max["x"]-6, self.max["y"]-4, 1 ) rectangle(self.screen, self.screen.getmaxyx()[0]-5, 0, self.max["y"]-3, self.max["x"]-5) self.screen.refresh() box = Textbox(editwin) # Let the user edit until Ctrl-G is struck. box.edit() # Get resulting contents message = box.gather() return(message)
def text_edit(text_to_display): stdscr = curses.initscr() curses.noecho() stdscr.addstr(0, 0, "%s: (hit Ctrl-G when finished)" % text_to_display) editwin = curses.newwin(20, 100, 2,1) rectangle(stdscr, 1,0, 1+20+1, 1+100+1) stdscr.refresh() box = Textbox(editwin) # Let the user edit until Ctrl-G is struck. box.edit() # Get resulting contents data = box.gather() curses.endwin() return data
def foo(stdscr): stdscr.addstr(0, 0, "Enter IM message: (hit Ctrl-G to send)") editwin = curses.newwin(5, 30, 2, 1) rectangle(stdscr, 1,0, 1+5+1, 1+30+1) stdscr.refresh() box = Textbox(editwin) #pad = curses.newpad(100, 100) height = 7; width = 33 begin_y = 1; begin_x = 33 win0 = curses.newwin(height, width, begin_y, begin_x) win0.border() win0.refresh() begin_y = 8; begin_x = 0 win1 = curses.newwin(height, width, begin_y, begin_x) win1.border() win1.refresh() begin_y = 8; begin_x = 33 win2 = curses.newwin(height, width, begin_y, begin_x) win2.border() win2.refresh() # Let the user edit until Ctrl-G is struck. box.edit() # Get resulting contents message = box.gather() win0.addstr(1,1,message) win1.addstr(1,1,message) win2.addstr(1,1,message) win0.refresh() win1.refresh() win2.refresh() stdscr.refresh() stdscr.getkey()
def print_ajouter_tag(self, tagMenu): tagMenu.getLastItemY() newTagStr = "New TAG >" self.screen.addstr(tagMenu.getLastItemY(), tagMenu.getFirstItemX()+len(tagMenu.getSelector())-len(newTagStr), newTagStr) editwin = curses.newwin( 1, self.max["x"]-tagMenu.getFirstItemX()+len(tagMenu.getSelector()), tagMenu.getLastItemY(), tagMenu.getFirstItemX()+len(tagMenu.getSelector()), ) self.screen.refresh() box = Textbox(editwin) # Let the user edit until Ctrl-G is struck. box.edit() # Get resulting contents message = box.gather() return(message)
def inputbox(self,message,title="Message Box"): """Displays a modal message box. Let's try not to use this much!""" self.scr.clear(); self.scr.addstr(0,0, "^G to commit."); self.scr.addstr(30,0, "----%s----"%title, curses.color_pair(9)); self.scr.addstr(31,0,message); editwin = curses.newwin(5,30, 2,1) rectangle(self.scr, 1,0, 1+5+1, 1+30+1) self.scr.refresh() box = Textbox(editwin) box.edit(); self.scr.clear(); return box.gather();
def lineEdit(theWorld, title, text=""): title = "/\\\\ %s //\\" % title win = curses.newwin(3, theWorld.w - 10, theWorld.h / 2 - 1, 6) win.box() size = win.getmaxyx() win.addstr(0, size[1] / 2 - len(title) / 2, title) win.refresh() win = curses.newwin(1, theWorld.w - 12, theWorld.h / 2, 7) t = Textbox(win) return t.edit()
def textEdit(theWorld, title, text=""): title = "/\\\\ %s //\\" % title win = curses.newwin(theWorld.h - 6, theWorld.w - 10, 3, 5) win.box() size = win.getmaxyx() win.addstr(0, size[1] / 2 - len(title) / 2, title) win.refresh() win = curses.newwin(theWorld.h - 8, theWorld.w - 12, 4, 6) win.addstr(text) t = Textbox(win) return t.edit()
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
def getString(inwin, title, init = None, default = None): namewin, cy, cx = centerWin(inwin, 3, 25) namewin.border() namewin.addstr(0,12-len(title)/2, title) editwin = namewin.subwin(1,23,cy+1,cx+1) if init != None: editwin.addstr(0,0,init) namewin.refresh() tbox = Textbox(editwin) validator = waxutil.Validator() result = tbox.edit(validator.validate).strip() namewin.clear() namewin.refresh() if len(result) == 0 or validator.abort: return default return result