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


Python curses.resizeterm方法代碼示例

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


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

示例1: update_size

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import resizeterm [as 別名]
def update_size(self):
        # get terminal size
        size = terminalsize.get_terminal_size()
        x = max(size[0], 10)
        y = max(size[1], 25)
        if (x, y) == (self.x, self.y):  # no need to resize
            return
        self.x, self.y = x, y

        # update intendations
        curses.resizeterm(self.y, self.x)
        self.startcol = int(float(self.x) / 5)
        self.indented_startcol = max(self.startcol - 3, 0)
        self.update_space()
        self.screen.clear()
        self.screen.refresh() 
開發者ID:darknessomi,項目名稱:musicbox,代碼行數:18,代碼來源:ui.py

示例2: resize

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import resizeterm [as 別名]
def resize(self):
        """Handle terminal resizing"""
        # Check if screen was re-sized (True or False)
        resize = self.max_x == 0 or \
            curses.is_term_resized(self.max_y, self.max_x)
        if resize is True:
            self.recalculate_layout()
            curses.resizeterm(self.max_y, self.max_x) 
開發者ID:OpenTrading,項目名稱:OpenTrader,代碼行數:10,代碼來源:tabview.py

示例3: resize

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import resizeterm [as 別名]
def resize(self):
        """Handles a resized terminal."""
        self.screen.redraw = True

        max_y, max_x = self.screen.window.getmaxyx()
        self.screen.clear()

        # Check if we have the resizeterm ncurses extension
        if hasattr(curses, "resizeterm"):
            curses.resizeterm(max_y, max_x)
            # An ungetch for KEY_RESIZE will be sent to let others handle it.
            # We'll just pop it off again to prevent endless loops.
            self.screen.get_key()

        self.screen.set_quote(self.quote)

        if self.start is not None and self.stop is None:
            # Resize during typing requires redrawing quote.
            self.screen.update_quote(Screen.COLOR_QUOTE)
            self.screen.update_author()

            if self.position + self.incorrect <= len(self.quote.text):
                for pos in range(self.position + 1):
                    self.screen.highlight_progress(pos, 0)
                for inc in range(self.incorrect + 1):
                    self.screen.highlight_progress(self.position, inc) 
開發者ID:cslarsen,項目名稱:wpm,代碼行數:28,代碼來源:game.py

示例4: resize

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import resizeterm [as 別名]
def resize(self):
        self.width, self.height = os.get_terminal_size()
        curses.resizeterm(self.height, self.width)
        self.angle_increment = 1 / self.width
        self.floor_y = self.height // 2
        self.distances = [0] * self.width 
開發者ID:salt-die,項目名稱:terminal_dungeon,代碼行數:8,代碼來源:renderer.py

示例5: test_resize_term

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import resizeterm [as 別名]
def test_resize_term(stdscr):
    if hasattr(curses, 'resizeterm'):
        lines, cols = curses.LINES, curses.COLS
        curses.resizeterm(lines - 1, cols + 1)

        if curses.LINES != lines - 1 or curses.COLS != cols + 1:
            raise RuntimeError, "Expected resizeterm to update LINES and COLS" 
開發者ID:ofermend,項目名稱:medicare-demo,代碼行數:9,代碼來源:test_curses.py

示例6: _patch_curses_resizeterm

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import resizeterm [as 別名]
def _patch_curses_resizeterm():
    if not hasattr(curses, "resizeterm"):
        assert hasattr(curses, "resize_term")
        curses.resizeterm = curses.resize_term 
開發者ID:guildai,項目名稱:guildai,代碼行數:6,代碼來源:tabview.py

示例7: resize

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import resizeterm [as 別名]
def resize(self, yx=None):
        """Resize UI to yx."""
        if yx is None:
            yx = self.screen.getmaxyx()
        self.screen.erase()
        curses.resizeterm(yx[0], yx[1])
        self.setup_windows() 
開發者ID:richrd,項目名稱:suplemon,代碼行數:9,代碼來源:ui.py

示例8: handleScreenResize

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import resizeterm [as 別名]
def handleScreenResize(self, window):
        #app.log.debug('handleScreenResize -----------------------')
        if sys.platform == 'darwin':
            # Some terminals seem to resize the terminal and others leave it
            # to the application to resize the curses terminal.
            rows, cols = app.curses_util.terminalSize()
            curses.resizeterm(rows, cols)
        self.top = self.left = 0
        self.rows, self.cols = app.window.mainCursesWindow.getmaxyx()
        self.layout()
        window.controller.onChange()
        self.render() 
開發者ID:google,項目名稱:ci_edit,代碼行數:14,代碼來源:program_window.py

示例9: start_view

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import resizeterm [as 別名]
def start_view(self, screen):
        self.screen = screen
        screen.keypad(False)

        (last_h, last_w) = screen.getmaxyx()
        refr = False
        self.refresh_all()

        while 1:
            (h, w) = screen.getmaxyx()
            self.height = h
            self.width = w

            if h != last_h or w != last_w:
                # TODO : resizing
                screen.erase()
                curses.resizeterm(h, w)
                last_h = h
                last_w = w
                refr = True
                if self.cursor_y > h:
                    self.cursor_y = h - 5
                    if self.cursor_y < 0:
                        self.cursor_y = 0
                if self.cursor_x > w:
                    self.cursor_x = w - 3

            wdgt = self.widgets[self.focus_widget_idx]

            if refr:
                wdgt.draw()
                refr = False

            wdgt.draw_cursor()
            wdgt.screen.refresh()

            k = self.read_escape_keys()
            refr = self.do_key(k)

            if wdgt.should_stop:
                wdgt.should_stop = False # because the console saves widgets
                screen.erase()
                return wdgt.value_selected

        screen.erase()
        return wdgt.value_selected 
開發者ID:plasma-disassembler,項目名稱:plasma,代碼行數:48,代碼來源:window.py

示例10: Redraw

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import resizeterm [as 別名]
def Redraw(self):

        self.stdscr.clear()
        if curses.is_term_resized(self.h, self.w):
            self.h, self.w = self.stdscr.getmaxyx()
            curses.resizeterm(self.h, self.w)

        i = 0

        i += self._titleyx(i, 0, "CONTROLLER")
        lines = str(self.controller).split("\n")
        i += self._printyx(i, 0, lines)

        def render_node(n):
            if n == self.controller.GetNodeId():
                return"node %d CONTROLLER" % n
            elif n in self.controller.failed_nodes:
                return"node %d FAILED" % n
            elif n in self.nodeset.nodes:
                node = self.nodeset.nodes[n]
                return "%s %s" % (node.Name(), node.state)
            else:
                return "Node %d  UNKNOWN" % n

        i += self._titleyx(i, 0, "NODES")
        nodes = set(self.controller.nodes) | self.nodeset.nodes.keys()
        lines = [render_node(n) for n in nodes]
        i += self._printyx(i, 0, lines)

        i += self._titleyx(i, 0, "QUEUE")
        lines = self.driver.OutQueueString().split("\n")
        i += self._printyx(i, 0, lines)

        i += self._titleyx(i, 0, "STATS")
        lines = MessageStatsString(self.driver.History()).split("\n")
        i += self._printyx(i, 0, lines)

        i = 1
        lines = [self.format(r) for r in self.messages[-self.h + 2:]]
        self._printyx(i, 81, lines)
        i += len(lines) + 1

        self.stdscr.refresh() 
開發者ID:robertmuth,項目名稱:PyZwaver,代碼行數:45,代碼來源:example_simple.py

示例11: setup_windows

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import resizeterm [as 別名]
def setup_windows(self):
        """Initialize and layout windows."""
        # We are using curses.newwin instead of self.screen.subwin/derwin because
        # subwindows are getting a special treatment on resize. e.g., the legend
        # bar may automatically resize to one line if the window gets smaller.
        # Even after doing the layout by moving the legend window into its proper
        # place a call to resize() to restore the 2 line height will error out.
        # This does not happen with curses.newwin().
        #
        # https://anonscm.debian.org/cgit/collab-maint/ncurses.git/tree/ncurses/base/resizeterm.c#n274
        # https://anonscm.debian.org/cgit/collab-maint/ncurses.git/tree/ncurses/base/wresize.c#n87
        self.text_input = None

        offset_top = 0
        offset_bottom = 0
        y, x = self.screen.getmaxyx()
        config = self.app.config["display"]

        if config["show_top_bar"]:
            offset_top += 1
            if self.header_win is None:
                self.header_win = curses.newwin(1, x, 0, 0)
            elif self.header_win.getmaxyx()[1] != x:
                # Header bar don't ever need to move
                self.header_win.resize(1, x)

        if config["show_bottom_bar"]:
            offset_bottom += 1
            if self.status_win is None:
                self.status_win = curses.newwin(1, x, y - offset_bottom, 0)
            else:
                self.status_win.mvwin(y - offset_bottom, 0)
                if self.status_win.getmaxyx()[1] != x:
                    self.status_win.resize(1, x)

        if config["show_legend"]:
            offset_bottom += 2
            if self.legend_win is None:
                self.legend_win = curses.newwin(2, x, y - offset_bottom, 0)
            else:
                self.legend_win.mvwin(y - offset_bottom, 0)
                if self.legend_win.getmaxyx()[1] != x:
                    self.legend_win.resize(2, x)

        if self.editor_win is None:
            self.editor_win = curses.newwin(y - offset_top - offset_bottom, x, offset_top, 0)
        else:
            # Not sure why editor implements this on its own
            # and if it's a good thing or not.
            self.app.get_editor().resize((y - offset_top - offset_bottom, x))
            self.app.get_editor().move_win((offset_top, 0))
            # self.editor_win.mvwin(offset_top, 0)
            # self.editor_win.resize(y - offset_top - offset_bottom, x) 
開發者ID:richrd,項目名稱:suplemon,代碼行數:55,代碼來源:ui.py


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