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


Python Terminal.fullscreen方法代码示例

本文整理汇总了Python中blessed.Terminal.fullscreen方法的典型用法代码示例。如果您正苦于以下问题:Python Terminal.fullscreen方法的具体用法?Python Terminal.fullscreen怎么用?Python Terminal.fullscreen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在blessed.Terminal的用法示例。


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

示例1: participant_context

# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import fullscreen [as 别名]
def participant_context(exp: Experiment, participant: ExperimentSection):
    term = Terminal()
    exp.session_data['term'] = term
    exp.session_data['stimuli'] = [
        jpg_to_ascii(os.path.join('stimuli', '{:02}.jpg'.format(i)), background='light', height=term.height - 2)
        for i in range(1, 16)
    ]

    with term.fullscreen():
        print(term.move(int(term.width//2), int(term.height//2)))
        response_type = participant.data['response_type']
        instructions = exp.experiment_data['instructions']
        for i, instruction in enumerate(instructions, 1):
            message = get_message(instruction, response_type)

            if message.startswith('_example'):
                show_example(term, response_type, message.split('_')[2], exp.session_data['stimuli'],
                             exp.experiment_data['example_response_message'],
                             ascii_stimuli=exp.experiment_data.get('ascii_stimuli', True),
                             stimulus_time=8)

            else:
                reset(term)
                wrapped_multiline_print_at_location(term, message, X_MARGIN, Y_MARGIN, int(term.width//2))
                with term.location(term.width//2, term.height - 3):
                    print('{}/{}'.format(i, len(instructions)))
                time.sleep(1)  # Ensure we don't accidentally skip a message.
                input()
        yield
        reset(term)
        print(exp.experiment_data['exit_message'])
        input()

    del exp.session_data['term']
开发者ID:hsharrison,项目名称:bistable-perception-experiment,代码行数:36,代码来源:experiment.py

示例2: main

# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import fullscreen [as 别名]
def main(logfilepath):
    
    term = Terminal()
    mngr = Manager(term, num_divisions=1, logfilepath=logfilepath)
    
    cursor, scrn = mngr.get_focus_cursor_and_screen()
    
    with term.hidden_cursor(), \
            term.raw(), \
            term.location(), \
            term.fullscreen(), \
            term.keypad():
        inp = None
        
        while True:
            inp = term.inkey(timeout=0.2)
            
            if inp != u'':
                signal = mngr.handle_input(inp)
                
                if signal == -1:
                    # got exit signal
                    break
            
            mngr.draw()
            
            if mngr.logger != None:
                mngr.logger.write_to_file()
开发者ID:bmer,项目名称:proofor,代码行数:30,代码来源:editor.py

示例3: main

# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import fullscreen [as 别名]
def main(argv=sys.argv[1:]):
	args = ArgumentParser()
	args.add_argument("-s", "--servers", default=DEFAULT_ES_SERVER,
		help='A list of elastic search servers seperated by "," against which to run queries (Default: %(default)s)')
	
	options = args.parse_args(argv)
	
	# post process argparsing results
	options.servers = [x.strip() for x in options.servers.split(",")]
	
	loop = asyncio.get_event_loop()
	t = Terminal()
	
	# Do this as a fullscreen app where possible to avoid poluting
	# terminal and screwing up cursor position
	with t.fullscreen():
		with t.cbreak():
			# this blank print statment forces blessings to go to 
			# 'all screen' mode as it wont send output out stdout
			# on its own
			print(t.clear)
			render_query_field(t, "")
			render_search_results(t, [])
	
			sys.stdout.flush()
	
			try:
				loop.run_until_complete(display_loop(t, options.servers))
			except KeyboardInterrupt:
				# We want to catch this as its out primary exit method. if
				# uncaught we end up displaying a interleaved (with old output)
				# stack trace that would incorectly lead users to assume they 
				# crashed the program
				print("Exiting")
开发者ID:exec-all,项目名称:numad,代码行数:36,代码来源:cmd.py

示例4: speed_read

# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import fullscreen [as 别名]
def speed_read(words, speed):
    term = Terminal()
    call(['clear'])
    with term.fullscreen():
        for w in words:
            printable = w.decode('utf-8')
            print(term.move_y(term.height // 2) + term.center(term.bold(printable)).rstrip())
            time.sleep(speed)
            call(["clear"])
开发者ID:encima,项目名称:scli,代码行数:11,代码来源:scli.py

示例5: run_8

# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import fullscreen [as 别名]
def run_8():
    term = Terminal()
    current_loc = (10, 10)
    loop = asyncio.get_event_loop()
    while True:
        future = asyncio.Future()
        asyncio.ensure_future(handle_keyboard_input(future, term))
        loop.run_until_complete(future)
        move_where = process_result(future.result(), term)
        current_loc = (sum(x) for x in zip(current_loc, move_where))
        with term.fullscreen(), term.location(*current_loc):
            print(move_where)
开发者ID:jbwincek,项目名称:Plie,代码行数:14,代码来源:event_handler_mockups.py

示例6: ascii_credits

# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import fullscreen [as 别名]
def ascii_credits():
    """
    Asciimatics credits!
    """
    term = Terminal()
    with term.fullscreen():
        with term.hidden_cursor():
            with term.cbreak():
                while True:
                    try:
                        _credits(term)
                        return
                    except ResizeScreenError:
                        pass
开发者ID:digideskio,项目名称:asciimatics,代码行数:16,代码来源:not_curses.py

示例7: run_7

# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import fullscreen [as 别名]
def run_7():
    term = Terminal()
    loop = asyncio.get_event_loop()
    #renderer = plie.Renderer(view=test_view)
    current_loc = (10,10)
    with term.fullscreen():
        while True:
            #renderer.display()
            future = asyncio.Future()
            asyncio.ensure_future(handle_keyboard_input(future, term))
            loop.run_until_complete(future)
            current_loc = process_result(future.result(), term, current_loc)
            with term.location(*current_loc):
                print('x',end='')
开发者ID:jbwincek,项目名称:Plie,代码行数:16,代码来源:event_handler_mockups.py

示例8: main

# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import fullscreen [as 别名]
def main():
    term = Terminal()
    csr = Cursor(0, 0, term)
    screen = {}
    with term.hidden_cursor(), \
            term.raw(), \
            term.location(), \
            term.fullscreen(), \
            term.keypad():
        inp = None
        while True:
            echo_yx(csr, term.reverse(screen.get((csr.y, csr.x), u' ')))
            inp = term.inkey()

            if inp == chr(3):
                # ^c exits
                break

            elif inp == chr(19):
                # ^s saves
                echo_yx(home(bottom(csr)),
                        term.ljust(term.bold_white('Filename: ')))
                echo_yx(right_of(home(bottom(csr)), len('Filename: ')), u'')
                save(screen, readline(term))
                echo_yx(home(bottom(csr)), term.clear_eol)
                redraw(term=term, screen=screen,
                       start=home(bottom(csr)),
                       end=end(bottom(csr)))
                continue

            elif inp == chr(12):
                # ^l refreshes
                redraw(term=term, screen=screen)

            n_csr = lookup_move(inp.code, csr, term)
            if n_csr != csr:
                # erase old cursor,
                echo_yx(csr, screen.get((csr.y, csr.x), u' '))
                csr = n_csr

            elif not inp.is_sequence and inp.isprintable():
                echo_yx(csr, inp)
                screen[(csr.y, csr.x)] = inp.__str__()
                n_csr = right_of(csr, 1)
                if n_csr == csr:
                    # wrap around margin
                    n_csr = home(below(csr, 1))
                csr = n_csr
开发者ID:JamesWKerr,项目名称:blessed,代码行数:50,代码来源:editor.py

示例9: main

# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import fullscreen [as 别名]
def main():
    term = Terminal()
    style = Style(heading=term.magenta,
                  hint=term.bright_cyan,
                  delimiter=u'|',
                  ) if term.number_of_colors else Style()
    screen = Screen(term, style)
    character_factory = WcWideCharacterGenerator
    pager = Pager(term, screen, character_factory)
    if term.is_a_tty:
        signal.signal(signal.SIGWINCH, pager.on_resize)
    else:
        screen.style.name_len = 80 - 15
        pager.dirty = 2
    with term.location(), term.cbreak(), term.fullscreen():
        pager.run(writer=echo, reader=term.inkey)
开发者ID:thomasballinger,项目名称:wcwidth,代码行数:18,代码来源:wcwidth-browser.py

示例10: main

# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import fullscreen [as 别名]
def main(opts):
    """Program entry point."""
    term = Terminal()
    style = Style()

    # if the terminal supports colors, use a Style instance with some
    # standout colors (magenta, cyan).
    if term.number_of_colors:
        style = Style(attr_major=term.magenta, attr_minor=term.bright_cyan, alignment=opts["--alignment"])
    style.name_len = term.width - 15

    screen = Screen(term, style, wide=opts["--wide"])
    pager = Pager(term, screen, opts["character_factory"])

    with term.location(), term.cbreak(), term.fullscreen(), term.hidden_cursor():
        pager.run(writer=echo, reader=term.inkey)
    return 0
开发者ID:jquast,项目名称:wcwidth,代码行数:19,代码来源:wcwidth-browser.py

示例11: main

# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import fullscreen [as 别名]
def main():
    words = ["exit", "select", "deselect", "status", "timeline", "readstream", 
        "oracle", "jobmanager",
        "cuttsum.trecdata.UrlListResource", "cuttsum.trecdata.SCChunkResource"]
    completer = Completer(words)
    readline.parse_and_bind("tab: complete")
    readline.set_completer(completer.complete)
    active_events = []
    all_events = cuttsum.events.get_events() 
    for e in all_events:
        print e.query_num
    t = Terminal()

    with t.fullscreen():
        while 1:
            home_screen(t, active_events)
            with t.location(0, t.height-1):
                cmd = raw_input(">>> ")
            args = cmd.split(" ")

            if args[0] == "select" and len(args) >= 2:
                cmd_select_events(
                    args[1:], active_events, all_events)
            elif args[0] == "deselect" and len(args) >= 2:
                active_events = cmd_deselect_events(
                    args[1:], active_events)
            elif args[0] == "timeline":
                print_event_timelines(t, active_events)
            elif args[0] == "status":
                cmd_status(args[1:], t, active_events)
            elif args[0] == "run":
                cmd_run(args[1:], t, active_events)

            elif args[0] == "readstream":
                cmd_readstream(args[1:], t, active_events)
            elif args[0] == "oracle":
                cmd_oracle(args[1:], t, active_events)
            elif args[0] == "jobmanager":
                from app.job_manager import start_job_manager
                start_job_manager(args[1:], t, active_events)
            elif args[0] == "exit":
                break
开发者ID:kedz,项目名称:cuttsum,代码行数:44,代码来源:trec-info.py

示例12: right_of

# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import fullscreen [as 别名]
    b.term.KEY_RIGHT: right_of(b, 1),
    b.term.KEY_DOWN: below(b, 1),
    b.term.KEY_UP: above(b, 1),
    # shift + arrows
    b.term.KEY_SLEFT: left_of(b, 10),
    b.term.KEY_SRIGHT: right_of(b, 10),
    b.term.KEY_SDOWN: below(b, 10),
    b.term.KEY_SUP: above(b, 10),
    # carriage return
    b.term.KEY_ENTER: home(below(b, 1)),
    b.term.KEY_HOME: home(b),
}.get(inp_code, b)

term = Terminal()
csr = Cursor(1, 1, term)
with term.hidden_cursor(), term.raw(), term.location(), term.fullscreen():
    inp = None
    while True:
        echo_xy(csr, term.reverse(u' '))
        inp = term.inkey()
        if inp.code == term.KEY_ESCAPE or inp == chr(3):
            break
        echo_xy(csr, u' ')
        n_csr = lookup_move(inp.code, csr)
        if n_csr != csr:
            echo_xy(n_csr, u' ')
            csr = n_csr
        elif not inp.is_sequence:
            echo_xy(csr, inp)
            csr = right_of(csr, 1)
开发者ID:lowks,项目名称:blessed,代码行数:32,代码来源:dumb_fse.py

示例13: tprint

# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import fullscreen [as 别名]
import sys
from blessed import Terminal
from multiprocessing import Pool, cpu_count
import numpy as np

origin_x, origin_y = 1, 1

def tprint(ustr):
    y = t.get_location()[0]
    x = t.get_location()[1]
    print(t.move(origin_y + y, origin_x + x) + str(ustr))

t = Terminal()
t.move(origin_y, origin_x)

with t.fullscreen():

    def worker(arr):
        return arr * 2 + 1

    tprint("Start processing data...")

    data_arr = np.random.rand(8, int(1e7))

    with Pool(cpu_count()) as p:
        buffer = p.map(worker, [data_arr[row] for row in np.ndindex(data_arr.shape[0])])

    tprint("...finished processing:")
    for row in buffer:
        tprint(row[0:3])
开发者ID:ascenator,项目名称:Python3Tests,代码行数:32,代码来源:blessed_multiprocessing_with_pool.py

示例14: BrowseRouters

# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import fullscreen [as 别名]
class BrowseRouters(message.MessageSending):

    log = logging.getLogger(__name__)
    SCHEMA = '''CREATE TABLE routers (
        id TEXT PRIMARY KEY,
        name TEXT,
        status TEXT,
        latest INTEGER,
        image_name TEXT,
        last_fetch TIMESTAMP,
        booted_at TIMESTAMP
    );'''

    def __init__(self, *a, **kw):
        self.term = Terminal()
        self.position = 0
        self.routers = []
        super(BrowseRouters, self).__init__(*a, **kw)

    def init_database(self):
        self.fh = tempfile.NamedTemporaryFile(delete=False)
        self.conn = sqlite3.connect(self.fh.name)
        self.conn.row_factory = RouterRow.from_cursor
        with closing(self.conn.cursor()) as cursor:
            cursor.execute(self.SCHEMA)

    def get_parser(self, prog_name):
        parser = super(BrowseRouters, self).get_parser(prog_name)
        parser.add_argument('--dump', dest='interactive', action='store_false')
        parser.add_argument('--threads', type=int, default=16)
        parser.set_defaults(interactive=True)
        return parser

    def take_action(self, parsed_args):
        self.interactive = parsed_args.interactive
        self.init_database()
        credentials = [
            cfg.CONF.admin_user,
            cfg.CONF.admin_password,
            cfg.CONF.admin_tenant_name,
            cfg.CONF.auth_url,
            cfg.CONF.auth_strategy,
            cfg.CONF.auth_region
        ]
        populate = threading.Thread(
            name='router-populater',
            target=populate_routers,
            args=(self.fh.name, credentials, parsed_args.threads)
        )
        populate.setDaemon(True)
        populate.start()
        self.handle_loop()

    def handle_loop(self):
        try:
            with self.term.fullscreen():
                with self.term.cbreak():
                    val = None
                    while val != u'q':
                        if not val:
                            self.fetch_routers()
                        elif val.is_sequence:
                            if val.code == self.term.KEY_DOWN:
                                self.move_down()
                            if val.code == self.term.KEY_UP:
                                self.move_up()
                        elif val == u'j':
                            self.move_down()
                        elif val == u'k':
                            self.move_up()
                        elif val == u'r':
                            self.rebuild_router()
                        if self.interactive:
                            self.print_routers()
                            val = self.term.inkey(timeout=3)
                        elif len(self.routers) and all(map(
                            lambda x: x.last_fetch, self.routers
                        )):
                            self.print_routers()
                            val = u'q'
                    self._exit()
        except KeyboardInterrupt:
            self._exit()
            raise

    def fetch_routers(self):
        with self.conn:
            cursor = self.conn.cursor()
            cursor.execute('SELECT * FROM routers ORDER BY id ASC;')
            self.routers = cursor.fetchall()

    @property
    def window(self):
        offset = 0
        routers = self.routers
        visible_height = self.term.height - 2
        if len(routers) > visible_height:
            offset = self.position
            offset = min(offset, len(routers) - visible_height - 1)
        return offset, routers[offset:(offset+visible_height+1)]
#.........这里部分代码省略.........
开发者ID:jordant,项目名称:akanda-rug,代码行数:103,代码来源:browse.py

示例15: monitor

# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import fullscreen [as 别名]
def monitor(run_once=False, broker=None):
    if not broker:
        broker = get_broker()
    term = Terminal()
    broker.ping()
    with term.fullscreen(), term.hidden_cursor(), term.cbreak():
        val = None
        start_width = int(term.width / 8)
        while val not in (u'q', u'Q',):
            col_width = int(term.width / 8)
            # In case of resize
            if col_width != start_width:
                print(term.clear())
                start_width = col_width
            print(term.move(0, 0) + term.black_on_green(term.center(_('Host'), width=col_width - 1)))
            print(term.move(0, 1 * col_width) + term.black_on_green(term.center(_('Id'), width=col_width - 1)))
            print(term.move(0, 2 * col_width) + term.black_on_green(term.center(_('State'), width=col_width - 1)))
            print(term.move(0, 3 * col_width) + term.black_on_green(term.center(_('Pool'), width=col_width - 1)))
            print(term.move(0, 4 * col_width) + term.black_on_green(term.center(_('TQ'), width=col_width - 1)))
            print(term.move(0, 5 * col_width) + term.black_on_green(term.center(_('RQ'), width=col_width - 1)))
            print(term.move(0, 6 * col_width) + term.black_on_green(term.center(_('RC'), width=col_width - 1)))
            print(term.move(0, 7 * col_width) + term.black_on_green(term.center(_('Up'), width=col_width - 1)))
            i = 2
            stats = Stat.get_all(broker=broker)
            print(term.clear_eos())
            for stat in stats:
                status = stat.status
                # color status
                if stat.status == Conf.WORKING:
                    status = term.green(str(Conf.WORKING))
                elif stat.status == Conf.STOPPING:
                    status = term.yellow(str(Conf.STOPPING))
                elif stat.status == Conf.STOPPED:
                    status = term.red(str(Conf.STOPPED))
                elif stat.status == Conf.IDLE:
                    status = str(Conf.IDLE)
                # color q's
                tasks = str(stat.task_q_size)
                if stat.task_q_size > 0:
                    tasks = term.cyan(str(stat.task_q_size))
                    if Conf.QUEUE_LIMIT and stat.task_q_size == Conf.QUEUE_LIMIT:
                        tasks = term.green(str(stat.task_q_size))
                results = stat.done_q_size
                if results > 0:
                    results = term.cyan(str(results))
                # color workers
                workers = len(stat.workers)
                if workers < Conf.WORKERS:
                    workers = term.yellow(str(workers))
                # format uptime
                uptime = (timezone.now() - stat.tob).total_seconds()
                hours, remainder = divmod(uptime, 3600)
                minutes, seconds = divmod(remainder, 60)
                uptime = '%d:%02d:%02d' % (hours, minutes, seconds)
                # print to the terminal
                print(term.move(i, 0) + term.center(stat.host[:col_width - 1], width=col_width - 1))
                print(term.move(i, 1 * col_width) + term.center(stat.cluster_id, width=col_width - 1))
                print(term.move(i, 2 * col_width) + term.center(status, width=col_width - 1))
                print(term.move(i, 3 * col_width) + term.center(workers, width=col_width - 1))
                print(term.move(i, 4 * col_width) + term.center(tasks, width=col_width - 1))
                print(term.move(i, 5 * col_width) + term.center(results, width=col_width - 1))
                print(term.move(i, 6 * col_width) + term.center(stat.reincarnations, width=col_width - 1))
                print(term.move(i, 7 * col_width) + term.center(uptime, width=col_width - 1))
                i += 1
            # bottom bar
            i += 1
            queue_size = broker.queue_size()
            lock_size = broker.lock_size()
            if lock_size:
                queue_size = '{}({})'.format(queue_size, lock_size)
            print(term.move(i, 0) + term.white_on_cyan(term.center(broker.info(), width=col_width * 2)))
            print(term.move(i, 2 * col_width) + term.black_on_cyan(term.center(_('Queued'), width=col_width)))
            print(term.move(i, 3 * col_width) + term.white_on_cyan(term.center(queue_size, width=col_width)))
            print(term.move(i, 4 * col_width) + term.black_on_cyan(term.center(_('Success'), width=col_width)))
            print(term.move(i, 5 * col_width) + term.white_on_cyan(
                term.center(models.Success.objects.count(), width=col_width)))
            print(term.move(i, 6 * col_width) + term.black_on_cyan(term.center(_('Failures'), width=col_width)))
            print(term.move(i, 7 * col_width) + term.white_on_cyan(
                term.center(models.Failure.objects.count(), width=col_width)))
            # for testing
            if run_once:
                return Stat.get_all(broker=broker)
            print(term.move(i + 2, 0) + term.center(_('[Press q to quit]')))
            val = term.inkey(timeout=1)
开发者ID:Koed00,项目名称:django-q,代码行数:86,代码来源:monitor.py


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