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


Python TaskView.resize方法代码示例

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


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

示例1: UI

# 需要导入模块: from ranger.gui.widgets.taskview import TaskView [as 别名]
# 或者: from ranger.gui.widgets.taskview.TaskView import resize [as 别名]
class UI(DisplayableContainer):
    is_set_up = False
    load_mode = False
    is_on = False
    termsize = None

    def __init__(self, env=None, fm=None):
        self.keybuffer = KeyBuffer()
        self.keymaps = KeyMaps(self.keybuffer)

        if fm is not None:
            self.fm = fm

    def setup_curses(self):
        os.environ['ESCDELAY'] = '25'   # don't know a cleaner way
        try:
            self.win = curses.initscr()
        except _curses.error as e:
            if e.args[0] == "setupterm: could not find terminal":
                os.environ['TERM'] = 'linux'
                self.win = curses.initscr()
        self.keymaps.use_keymap('browser')
        DisplayableContainer.__init__(self, None)

    def initialize(self):
        """initialize curses, then call setup (at the first time) and resize."""
        self.win.leaveok(0)
        self.win.keypad(1)
        self.load_mode = False

        curses.cbreak()
        curses.noecho()
        curses.halfdelay(20)
        try:
            curses.curs_set(int(bool(self.settings.show_cursor)))
        except:
            pass
        curses.start_color()
        curses.use_default_colors()

        self.settings.signal_bind('setopt.mouse_enabled', _setup_mouse)
        _setup_mouse(dict(value=self.settings.mouse_enabled))

        if not self.is_set_up:
            self.is_set_up = True
            self.setup()
            self.win.addstr("loading...")
            self.win.refresh()
            self._draw_title = curses.tigetflag('hs') # has_status_line
        self.update_size()
        self.is_on = True

        if self.settings.update_tmux_title:
            sys.stdout.write("\033kranger\033\\")
            sys.stdout.flush()

    def suspend(self):
        """Turn off curses"""
        self.win.keypad(0)
        curses.nocbreak()
        curses.echo()
        try:
            curses.curs_set(1)
        except:
            pass
        if self.settings.mouse_enabled:
            _setup_mouse(dict(value=False))
        curses.endwin()
        self.is_on = False

    def set_load_mode(self, boolean):
        boolean = bool(boolean)
        if boolean != self.load_mode:
            self.load_mode = boolean

            if boolean:
                # don't wait for key presses in the load mode
                curses.cbreak()
                self.win.nodelay(1)
            else:
                self.win.nodelay(0)
                curses.halfdelay(20)

    def destroy(self):
        """Destroy all widgets and turn off curses"""
        DisplayableContainer.destroy(self)
        self.suspend()

    def handle_mouse(self):
        """Handles mouse input"""
        try:
            event = MouseEvent(curses.getmouse())
        except _curses.error:
            return
        if not self.console.visible:
            DisplayableContainer.click(self, event)

    def handle_key(self, key):
        """Handles key input"""

#.........这里部分代码省略.........
开发者ID:niksfirefly,项目名称:ranger,代码行数:103,代码来源:ui.py

示例2: UI

# 需要导入模块: from ranger.gui.widgets.taskview import TaskView [as 别名]
# 或者: from ranger.gui.widgets.taskview.TaskView import resize [as 别名]
class UI(DisplayableContainer):
    is_set_up = False
    load_mode = False
    is_on = False

    def __init__(self, env=None, fm=None):
        self._draw_title = os.environ["TERM"] in TERMINALS_WITH_TITLE
        os.environ["ESCDELAY"] = "25"  # don't know a cleaner way

        if env is not None:
            self.env = env
        if fm is not None:
            self.fm = fm

        try:
            self.win = curses.initscr()
        except _curses.error as e:
            if e.args[0] == "setupterm: could not find terminal":
                os.environ["TERM"] = "linux"
                self.win = curses.initscr()
        self.env.keymaps.use_keymap("browser")

        DisplayableContainer.__init__(self, None)

    def initialize(self):
        """initialize curses, then call setup (at the first time) and resize."""
        self.win.leaveok(0)
        self.win.keypad(1)
        self.load_mode = False

        curses.cbreak()
        curses.noecho()
        curses.halfdelay(20)
        try:
            curses.curs_set(int(bool(self.settings.show_cursor)))
        except:
            pass
        curses.start_color()
        curses.use_default_colors()

        self.settings.signal_bind("setopt.mouse_enabled", _setup_mouse)
        _setup_mouse(dict(value=self.settings.mouse_enabled))

        if not self.is_set_up:
            self.is_set_up = True
            self.setup()
            self.win.addstr("loading...")
            self.win.refresh()
        self.update_size()
        self.is_on = True

    def suspend(self):
        """Turn off curses"""
        self.win.keypad(0)
        curses.nocbreak()
        curses.echo()
        try:
            curses.curs_set(1)
        except:
            pass
        if self.settings.mouse_enabled:
            _setup_mouse(dict(value=False))
        curses.endwin()
        self.is_on = False

    def set_load_mode(self, boolean):
        boolean = bool(boolean)
        if boolean != self.load_mode:
            self.load_mode = boolean

            if boolean:
                # don't wait for key presses in the load mode
                curses.cbreak()
                self.win.nodelay(1)
            else:
                self.win.nodelay(0)
                curses.halfdelay(20)

    def destroy(self):
        """Destroy all widgets and turn off curses"""
        self.suspend()
        DisplayableContainer.destroy(self)

    def handle_mouse(self):
        """Handles mouse input"""
        try:
            event = MouseEvent(curses.getmouse())
        except _curses.error:
            return
        if not self.console.visible:
            DisplayableContainer.click(self, event)

    def handle_key(self, key):
        """Handles key input"""

        if hasattr(self, "hint"):
            self.hint()

        if key < 0:
            self.env.keybuffer.clear()
#.........这里部分代码省略.........
开发者ID:sharklasers,项目名称:livarp_0.3.9,代码行数:103,代码来源:ui.py

示例3: UI

# 需要导入模块: from ranger.gui.widgets.taskview import TaskView [as 别名]
# 或者: from ranger.gui.widgets.taskview.TaskView import resize [as 别名]
class UI(  # pylint: disable=too-many-instance-attributes,too-many-public-methods
        DisplayableContainer):
    ALLOWED_VIEWMODES = 'miller', 'multipane'

    is_set_up = False
    load_mode = False
    is_on = False
    termsize = None

    def __init__(self, env=None, fm=None):  # pylint: disable=super-init-not-called
        self.keybuffer = KeyBuffer()
        self.keymaps = KeyMaps(self.keybuffer)
        self.redrawlock = threading.Event()
        self.redrawlock.set()

        self.titlebar = None
        self._viewmode = None
        self.taskview = None
        self.status = None
        self.console = None
        self.pager = None
        self._draw_title = None
        self._tmux_automatic_rename = None
        self.browser = None

        if fm is not None:
            self.fm = fm

    def setup_curses(self):
        os.environ['ESCDELAY'] = '25'   # don't know a cleaner way
        try:
            self.win = curses.initscr()
        except curses.error as ex:
            if ex.args[0] == "setupterm: could not find terminal":
                os.environ['TERM'] = 'linux'
                self.win = curses.initscr()
        self.keymaps.use_keymap('browser')
        DisplayableContainer.__init__(self, None)

    def initialize(self):
        """initialize curses, then call setup (at the first time) and resize."""
        self.win.leaveok(0)
        self.win.keypad(1)
        self.load_mode = False

        curses.cbreak()
        curses.noecho()
        curses.halfdelay(20)
        try:
            curses.curs_set(int(bool(self.settings.show_cursor)))
        except curses.error:
            pass
        curses.start_color()
        try:
            curses.use_default_colors()
        except curses.error:
            pass

        self.settings.signal_bind('setopt.mouse_enabled', _setup_mouse)
        self.settings.signal_bind('setopt.freeze_files', self.redraw_statusbar)
        _setup_mouse(dict(value=self.settings.mouse_enabled))

        if not self.is_set_up:
            self.is_set_up = True
            self.setup()
            self.win.addstr("loading...")
            self.win.refresh()
            self._draw_title = curses.tigetflag('hs')  # has_status_line

            # Save tmux setting `automatic-rename`
            if self.settings.update_tmux_title and 'TMUX' in os.environ:
                try:
                    self._tmux_automatic_rename = check_output(
                        ['tmux', 'show-window-options', '-v', 'automatic-rename']).strip()
                except CalledProcessError:
                    self._tmux_automatic_rename = None

        self.update_size()
        self.is_on = True

        if self.settings.update_tmux_title and 'TMUX' in os.environ:
            sys.stdout.write("\033kranger\033\\")
            sys.stdout.flush()

        if 'vcsthread' in self.__dict__:
            self.vcsthread.unpause()

    def suspend(self):
        """Turn off curses"""
        if 'vcsthread' in self.__dict__:
            self.vcsthread.pause()
            self.vcsthread.paused.wait()

        self.win.keypad(0)
        curses.nocbreak()
        curses.echo()
        try:
            curses.curs_set(1)
        except curses.error:
            pass
#.........这里部分代码省略.........
开发者ID:sergeyguzhev,项目名称:ranger,代码行数:103,代码来源:ui.py

示例4: DefaultUI

# 需要导入模块: from ranger.gui.widgets.taskview import TaskView [as 别名]
# 或者: from ranger.gui.widgets.taskview.TaskView import resize [as 别名]
class DefaultUI(UI):
	def setup(self):
		"""Build up the UI by initializing widgets."""
		# Create a title bar
		self.titlebar = TitleBar(self.win)
		self.add_child(self.titlebar)

		# Create the browser view
		self.browser = BrowserView(self.win, self.settings.column_ratios)
		self.settings.signal_bind('setopt.column_ratios',
				self.browser.change_ratios)
		self.add_child(self.browser)

		# Create the process manager
		self.taskview = TaskView(self.win)
		self.taskview.visible = False
		self.add_child(self.taskview)

		# Create the status bar
		self.status = StatusBar(self.win, self.browser.main_column)
		self.add_child(self.status)

		# Create the console
		self.console = Console(self.win)
		self.add_child(self.console)
		self.console.visible = False

		# Create the pager
		self.pager = Pager(self.win)
		self.pager.visible = False
		self.add_child(self.pager)

	def update_size(self):
		"""resize all widgets"""
		UI.update_size(self)
		y, x = self.env.termsize

		self.browser.resize(1, 0, y - 2, x)
		self.taskview.resize(1, 0, y - 2, x)
		self.pager.resize(1, 0, y - 2, x)
		self.titlebar.resize(0, 0, 1, x)
		self.status.resize(y - 1, 0, 1, x)
		self.console.resize(y - 1, 0, 1, x)

	def notify(self, *a, **k):
		return self.status.notify(*a, **k)

	def close_pager(self):
		if self.console.visible:
			self.console.focused = True
		self.pager.close()
		self.pager.visible = False
		self.pager.focused = False
		self.browser.visible = True

	def open_pager(self):
		if self.console.focused:
			self.console.focused = False
		self.pager.open()
		self.pager.visible = True
		self.pager.focused = True
		self.browser.visible = False
		return self.pager

	def open_embedded_pager(self):
		self.browser.open_pager()
		return self.browser.pager

	def close_embedded_pager(self):
		self.browser.close_pager()

	def open_console(self, string='', prompt=None, position=None):
		if self.console.open(string, prompt=prompt, position=position):
			self.status.msg = None
			self.console.on_close = self.close_console
			self.console.visible = True
			self.status.visible = False

	def close_console(self):
		self.console.visible = False
		self.status.visible = True
		self.close_pager()

	def open_taskview(self):
		self.pager.close()
		self.pager.visible = False
		self.pager.focused = False
		self.console.visible = False
		self.browser.visible = False
		self.taskview.visible = True
		self.taskview.focused = True
		self.fm.hint('*tasks:* *dd*:remove *J*:move_down *H*:move_up')

	def redraw_main_column(self):
		self.browser.main_column.need_redraw = True

	def close_taskview(self):
		self.taskview.visible = False
		self.browser.visible = True
		self.taskview.focused = False
#.........这里部分代码省略.........
开发者ID:dpaneda,项目名称:ranger,代码行数:103,代码来源:defaultui.py


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