当前位置: 首页>>代码示例>>Python>>正文


Python textpad.Textbox类代码示例

本文整理汇总了Python中curses.textpad.Textbox的典型用法代码示例。如果您正苦于以下问题:Python Textbox类的具体用法?Python Textbox怎么用?Python Textbox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Textbox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _display

    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
开发者ID:kondziu,项目名称:6p,代码行数:26,代码来源:cli.py

示例2: draw_edit_box

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")
开发者ID:qrthur,项目名称:freebsd-builder-rpi,代码行数:27,代码来源:curses_gui.py

示例3: main

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)
开发者ID:mayukuse24,项目名称:teditor,代码行数:25,代码来源:main.py

示例4: insertFile

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
开发者ID:kidaa,项目名称:bttext,代码行数:26,代码来源:editor.py

示例5: init

def init():
    global stdscr, chatlog_win, input_win, players_win, input_textbox

    stdscr = curses.initscr()
    curses.cbreak()
    curses.noecho()
    stdscr.keypad(1)

    h, w = stdscr.getmaxyx()
    PNW = 20  # player name width
    INH = 4   # input window height

    stdscr.vline(0, w - PNW - 1, curses.ACS_VLINE, h)
    stdscr.hline(h - INH - 1, 0, curses.ACS_HLINE, w - PNW - 1)

    chatlog_win = curses.newwin(h - INH - 1, w - PNW - 1, 0, 0)
    input_win = curses.newwin(INH, w - PNW - 1, h - INH, 0)
    players_win = curses.newwin(h, PNW, 0, w - PNW)

    chatlog_win.idlok(1)
    chatlog_win.scrollok(1)

    players_win.idlok(1)
    players_win.scrollok(1)

    input_textbox = Textbox(input_win)
    input_textbox.stripspaces = True

    stdscr.noutrefresh()
    input_win.noutrefresh()
    players_win.noutrefresh()
    chatlog_win.noutrefresh()

    curses.doupdate()
开发者ID:Tezer123,项目名称:manachat,代码行数:34,代码来源:cui.py

示例6: main_control

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)
开发者ID:albang,项目名称:clitodo,代码行数:32,代码来源:Vue.py

示例7: main

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)
开发者ID:aixr,项目名称:EncryptedChat,代码行数:27,代码来源:client.py

示例8: _main

    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()
开发者ID:netixx,项目名称:NetProbes,代码行数:32,代码来源:curses.py

示例9: run_curses

 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)
开发者ID:eswald,项目名称:parlance,代码行数:8,代码来源:chatty.py

示例10: main

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()
开发者ID:redevined,项目名称:ArgusCLI,代码行数:58,代码来源:main.py

示例11: main

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()
开发者ID:Achoi8917,项目名称:ICS4U-PCP,代码行数:57,代码来源:coor.py

示例12: textbox

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
开发者ID:FailureTowne,项目名称:ncurses-UI,代码行数:9,代码来源:capstone.py

示例13: switch_buffer

 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])
开发者ID:aliceriot,项目名称:cup.py,代码行数:10,代码来源:editor.py

示例14: drawLoginInput

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
开发者ID:lolwat97,项目名称:our-uplink,代码行数:10,代码来源:loginscreen.py

示例15: main

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()
开发者ID:EEEden,项目名称:chat,代码行数:10,代码来源:cursestest.py


注:本文中的curses.textpad.Textbox类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。