本文整理匯總了Python中ranger.gui.widgets.console.Console.open方法的典型用法代碼示例。如果您正苦於以下問題:Python Console.open方法的具體用法?Python Console.open怎麽用?Python Console.open使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ranger.gui.widgets.console.Console
的用法示例。
在下文中一共展示了Console.open方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: UI
# 需要導入模塊: from ranger.gui.widgets.console import Console [as 別名]
# 或者: from ranger.gui.widgets.console.Console import open [as 別名]
#.........這裏部分代碼省略.........
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(self.settings.status_bar_on_top and 1 or y-1, 0, 1, x)
self.console.resize(y - 1, 0, 1, x)
def draw(self):
"""Draw all objects in the container"""
self.win.touchwin()
DisplayableContainer.draw(self)
if self._draw_title and self.settings.update_title:
cwd = self.fm.thisdir.path
if cwd.startswith(self.fm.home_path):
cwd = '~' + cwd[len(self.fm.home_path):]
if self.settings.shorten_title:
split = cwd.rsplit(os.sep, self.settings.shorten_title)
if os.sep in split[0]:
cwd = os.sep.join(split[1:])
try:
fixed_cwd = cwd.encode('utf-8', 'surrogateescape'). \
decode('utf-8', 'replace')
sys.stdout.write("%sranger:%s%s" %
(curses.tigetstr('tsl').decode('latin-1'), fixed_cwd,
curses.tigetstr('fsl').decode('latin-1')))
sys.stdout.flush()
except:
pass
self.win.refresh()
def finalize(self):
"""Finalize every object in container and refresh the window"""
DisplayableContainer.finalize(self)
self.win.refresh()
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):
self.browser.columns[-1].clear_image(force=True)
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()
for column in self.browser.columns:
if column == self.browser.main_column:
break
column.level_shift(amount=1)
return self.browser.pager
def close_embedded_pager(self):
self.browser.close_pager()
for column in self.browser.columns:
column.level_restore()
def open_console(self, string='', prompt=None, position=None):
if self.console.open(string, prompt=prompt, position=position):
self.status.msg = None
def close_console(self):
self.console.close()
self.close_pager()
def open_taskview(self):
self.browser.columns[-1].clear_image(force=True)
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
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
def throbber(self, string='.', remove=False):
if remove:
self.titlebar.throbber = type(self.titlebar).throbber
else:
self.titlebar.throbber = string
def hint(self, text=None):
self.status.hint = text
示例2: UI
# 需要導入模塊: from ranger.gui.widgets.console import Console [as 別名]
# 或者: from ranger.gui.widgets.console.Console import open [as 別名]
#.........這裏部分代碼省略.........
self.win.refresh()
self.win.redrawwin()
self.need_redraw = True
def update_size(self):
"""resize all widgets"""
self.env.termsize = self.win.getmaxyx()
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 draw(self):
"""Draw all objects in the container"""
self.win.touchwin()
DisplayableContainer.draw(self)
if self._draw_title and self.settings.update_title:
cwd = self.fm.env.cwd.path
if cwd.startswith(self.env.home_path):
cwd = "~" + cwd[len(self.env.home_path) :]
if self.settings.shorten_title:
split = cwd.rsplit(os.sep, self.settings.shorten_title)
if os.sep in split[0]:
cwd = os.sep.join(split[1:])
try:
sys.stdout.write("\033]2;ranger:" + cwd + "\007")
except UnicodeEncodeError:
sys.stdout.write("\033]2;ranger:" + ascii_only(cwd) + "\007")
self.win.refresh()
def finalize(self):
"""Finalize every object in container and refresh the window"""
DisplayableContainer.finalize(self)
self.win.refresh()
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
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
def throbber(self, string=".", remove=False):
if remove:
self.titlebar.throbber = type(self.titlebar).throbber
else:
self.titlebar.throbber = string
def hint(self, text=None):
self.status.hint = text
示例3: UI
# 需要導入模塊: from ranger.gui.widgets.console import Console [as 別名]
# 或者: from ranger.gui.widgets.console.Console import open [as 別名]
#.........這裏部分代碼省略.........
fixed_cwd,
curses.tigetstr('fsl').decode('latin-1'),
)
except UnicodeError:
pass
else:
sys.stdout.write("%sranger:%s%s" % fmt_tup)
sys.stdout.flush()
self.win.refresh()
def finalize(self):
"""Finalize every object in container and refresh the window"""
DisplayableContainer.finalize(self)
self.win.refresh()
def draw_images(self):
if self.pager.visible:
self.pager.draw_image()
elif self.browser.pager:
if self.browser.pager.visible:
self.browser.pager.draw_image()
else:
self.browser.columns[-1].draw_image()
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):
self.browser.columns[-1].clear_image(force=True)
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()
for column in self.browser.columns:
if column == self.browser.main_column:
break
column.level_shift(amount=1)
return self.browser.pager
def close_embedded_pager(self):
self.browser.close_pager()
for column in self.browser.columns:
column.level_restore()
def open_console(self, string='', prompt=None, position=None):
if self.console.open(string, prompt=prompt, position=position):
self.status.msg = None
def close_console(self):
self.console.close()
self.close_pager()
def open_taskview(self):
self.browser.columns[-1].clear_image(force=True)
示例4: DefaultUI
# 需要導入模塊: from ranger.gui.widgets.console import Console [as 別名]
# 或者: from ranger.gui.widgets.console.Console import open [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
#.........這裏部分代碼省略.........