當前位置: 首頁>>代碼示例>>Python>>正文


Python screen.Size方法代碼示例

本文整理匯總了Python中prompt_toolkit.layout.screen.Size方法的典型用法代碼示例。如果您正苦於以下問題:Python screen.Size方法的具體用法?Python screen.Size怎麽用?Python screen.Size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在prompt_toolkit.layout.screen的用法示例。


在下文中一共展示了screen.Size方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_size

# 需要導入模塊: from prompt_toolkit.layout import screen [as 別名]
# 或者: from prompt_toolkit.layout.screen import Size [as 別名]
def get_size(self):
        from prompt_toolkit.layout.screen import Size
        info = self.get_win32_screen_buffer_info()

        # We take the width of the *visible* region as the size. Not the width
        # of the complete screen buffer. (Unless use_complete_width has been
        # set.)
        if self.use_complete_width:
            width = info.dwSize.X
        else:
            width = info.srWindow.Right - info.srWindow.Left

        height = info.srWindow.Bottom - info.srWindow.Top + 1

        # We avoid the right margin, windows will wrap otherwise.
        maxwidth = info.dwSize.X - 1
        width = min(maxwidth, width)

        # Create `Size` object.
        return Size(rows=height, columns=width) 
開發者ID:chrisjim316,項目名稱:Liljimbo-Chatbot,代碼行數:22,代碼來源:win32_output.py

示例2: __init__

# 需要導入模塊: from prompt_toolkit.layout import screen [as 別名]
# 或者: from prompt_toolkit.layout.screen import Size [as 別名]
def __init__(self, conn, addr, application, server, encoding):
        assert isinstance(addr, tuple)  # (addr, port) tuple
        assert isinstance(application, TelnetApplication)
        assert isinstance(server, TelnetServer)
        assert isinstance(encoding, text_type)  # e.g. 'utf-8'

        self.conn = conn
        self.addr = addr
        self.application = application
        self.closed = False
        self.handling_command = True
        self.server = server
        self.encoding = encoding
        self.callback = None  # Function that handles the CLI result.

        # Create "Output" object.
        self.size = Size(rows=40, columns=79)

        # Initialize.
        _initialize_telnet(conn)

        # Create output.
        def get_size():
            return self.size
        self.stdout = _ConnectionStdout(conn, encoding=encoding)
        self.vt100_output = Vt100_Output(self.stdout, get_size, write_binary=False)

        # Create an eventloop (adaptor) for the CommandLineInterface.
        self.eventloop = _TelnetEventLoopInterface(server)

        # Set default CommandLineInterface.
        self.set_application(create_prompt_application())

        # Call client_connected
        application.client_connected(self)

        # Draw for the first time.
        self.handling_command = False
        self.cli._redraw() 
開發者ID:chrisjim316,項目名稱:Liljimbo-Chatbot,代碼行數:41,代碼來源:server.py

示例3: get_size

# 需要導入模塊: from prompt_toolkit.layout import screen [as 別名]
# 或者: from prompt_toolkit.layout.screen import Size [as 別名]
def get_size(self):
        return Size(rows=40, columns=80) 
開發者ID:chrisjim316,項目名稱:Liljimbo-Chatbot,代碼行數:4,代碼來源:output.py

示例4: from_pty

# 需要導入模塊: from prompt_toolkit.layout import screen [as 別名]
# 或者: from prompt_toolkit.layout.screen import Size [as 別名]
def from_pty(cls, stdout, true_color=False, ansi_colors_only=None, term=None):
        """
        Create an Output class from a pseudo terminal.
        (This will take the dimensions by reading the pseudo
        terminal attributes.)
        """
        assert stdout.isatty()
        def get_size():
            rows, columns = _get_size(stdout.fileno())
            # If terminal (incorrectly) reports its size as 0, pick a reasonable default.
            # See https://github.com/ipython/ipython/issues/10071
            return Size(rows=(rows or 24), columns=(columns or 80))

        return cls(stdout, get_size, true_color=true_color,
                   ansi_colors_only=ansi_colors_only, term=term) 
開發者ID:chrisjim316,項目名稱:Liljimbo-Chatbot,代碼行數:17,代碼來源:vt100_output.py

示例5: from_pty

# 需要導入模塊: from prompt_toolkit.layout import screen [as 別名]
# 或者: from prompt_toolkit.layout.screen import Size [as 別名]
def from_pty(cls, stdout, true_color=False, ansi_colors_only=None, term=None):
        """
        Create an Output class from a pseudo terminal.
        (This will take the dimensions by reading the pseudo
        terminal attributes.)
        """
        assert stdout.isatty()

        def get_size():
            rows, columns = _get_size(stdout.fileno())
            return Size(rows=rows, columns=columns)

        return cls(stdout, get_size, true_color=true_color,
                   ansi_colors_only=ansi_colors_only, term=term) 
開發者ID:randy3k,項目名稱:rice,代碼行數:16,代碼來源:vt100.py

示例6: from_pty

# 需要導入模塊: from prompt_toolkit.layout import screen [as 別名]
# 或者: from prompt_toolkit.layout.screen import Size [as 別名]
def from_pty(cls, stdout, true_color=False, ansi_colors_only=None, term=None):
        """
        Create an Output class from a pseudo terminal.
        (This will take the dimensions by reading the pseudo
        terminal attributes.)
        """
        assert stdout.isatty()
        def get_size():
            rows, columns = _get_size(stdout.fileno())
            return Size(rows=rows, columns=columns)

        return cls(stdout, get_size, true_color=true_color,
                   ansi_colors_only=ansi_colors_only, term=term) 
開發者ID:Desgard,項目名稱:Repobot,代碼行數:15,代碼來源:vt100_output.py

示例7: set_application

# 需要導入模塊: from prompt_toolkit.layout import screen [as 別名]
# 或者: from prompt_toolkit.layout.screen import Size [as 別名]
def set_application(self, app, callback=None):
        """
        Set ``CommandLineInterface`` instance for this connection.
        (This can be replaced any time.)

        :param cli: CommandLineInterface instance.
        :param callback: Callable that takes the result of the CLI.
        """
        assert isinstance(app, Application)
        assert callback is None or callable(callback)

        self.cli = CommandLineInterface(
            application=app,
            eventloop=self.eventloop,
            output=self.vt100_output)
        self.callback = callback

        # Create a parser, and parser callbacks.
        cb = self.cli.create_eventloop_callbacks()
        inputstream = InputStream(cb.feed_key)

        # Input decoder for stdin. (Required when working with multibyte
        # characters, like chinese input.)
        stdin_decoder_cls = getincrementaldecoder(self.encoding)
        stdin_decoder = [stdin_decoder_cls()]  # nonlocal

        # Tell the CLI that it's running. We don't start it through the run()
        # call, but will still want _redraw() to work.
        self.cli._is_running = True

        def data_received(data):
            """ TelnetProtocolParser 'data_received' callback """
            assert isinstance(data, binary_type)

            try:
                result = stdin_decoder[0].decode(data)
                inputstream.feed(result)
            except UnicodeDecodeError:
                stdin_decoder[0] = stdin_decoder_cls()
                return ''

        def size_received(rows, columns):
            """ TelnetProtocolParser 'size_received' callback """
            self.size = Size(rows=rows, columns=columns)
            cb.terminal_size_changed()

        self.parser = TelnetProtocolParser(data_received, size_received) 
開發者ID:chrisjim316,項目名稱:Liljimbo-Chatbot,代碼行數:49,代碼來源:server.py

示例8: __init__

# 需要導入模塊: from prompt_toolkit.layout import screen [as 別名]
# 或者: from prompt_toolkit.layout.screen import Size [as 別名]
def __init__(self, conn, addr, interact, server, encoding, style):
        assert isinstance(addr, tuple)  # (addr, port) tuple
        assert callable(interact)
        assert isinstance(server, TelnetServer)
        assert isinstance(encoding, text_type)  # e.g. 'utf-8'
        assert isinstance(style, BaseStyle)

        self.conn = conn
        self.addr = addr
        self.interact = interact
        self.server = server
        self.encoding = encoding
        self.style = style
        self._closed = False

        # Execution context.
        self._context_id = None

        # Create "Output" object.
        self.size = Size(rows=40, columns=79)

        # Initialize.
        _initialize_telnet(conn)

        # Create input.
        self.vt100_input = PipeInput()

        # Create output.
        def get_size():
            return self.size
        self.stdout = _ConnectionStdout(conn, encoding=encoding)
        self.vt100_output = Vt100_Output(
            self.stdout, get_size, write_binary=False)

        def data_received(data):
            """ TelnetProtocolParser 'data_received' callback """
            assert isinstance(data, binary_type)
            self.vt100_input.send_bytes(data)

        def size_received(rows, columns):
            """ TelnetProtocolParser 'size_received' callback """
            self.size = Size(rows=rows, columns=columns)
            get_app()._on_resize()

        self.parser = TelnetProtocolParser(data_received, size_received) 
開發者ID:randy3k,項目名稱:rice,代碼行數:47,代碼來源:server.py


注:本文中的prompt_toolkit.layout.screen.Size方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。