本文整理汇总了Python中view.View.resize方法的典型用法代码示例。如果您正苦于以下问题:Python View.resize方法的具体用法?Python View.resize怎么用?Python View.resize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类view.View
的用法示例。
在下文中一共展示了View.resize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Controller
# 需要导入模块: from view import View [as 别名]
# 或者: from view.View import resize [as 别名]
class Controller(object):
""" Window/keyboard controller. """
def __init__(self):
self.model = Model()
self.view = View()
self.socket = UDSClient()
self.socket.register(Protocol.FULL_HISTORY, self.model.history.set)
self.socket.register(Protocol.NEW_ENTRY, self.model.history.add)
self.commands = {"q": self._quit,
"j": lambda: self.view.change_pointer(1),
"k": lambda: self.view.change_pointer(-1),
"y": lambda: self._copy_pointed(None),
"u": lambda: self._copy_pointed("lower"),
"U": lambda: self._copy_pointed("upper"),
"v|V": self._toggle_details_view,
"\t": self._toggle_match_url,
r'\+': lambda: self.view.resize(1),
r'\-': lambda: self.view.resize(-1),
r'/(.*)[^\]]$': self._search}
self.running = True
def _search(self):
"Prepare to filter items by search term."
self.model.set_search()
self.view.highlighted_item = 0
self.view.pointer = 0
def _quit(self):
"Update state so that everyone knows the program should close."
self.running = False
def _clear_buffer(self, how_much=None):
"Clear keyboard buffer."
if how_much is None:
how_much = len(self.model.kb_buffer)
self.model.kb_buffer = self.model.kb_buffer[:-how_much]
def _toggle_details_view(self):
"Show/hide details view."
self.view.details_window_show = not self.view.details_window_show
def _toggle_match_url(self):
"Toggle the match url toggle."
self.model.match_url = not self.model.match_url
self.view.highlighted_item = 0
self.view.pointer = 0
def _copy_pointed(self, mode=""):
"""Copy an item into the clipboard.
Can copy as all upper or all lower, depending on mode chosen."""
pointed = self.model.filtered_items[self.view.pointer].encode("utf-8")
write_text = pointed.upper() if mode == "upper" else \
pointed.lower() if mode == "lower" else \
pointed
ClipboardFactory.create().put_text(write_text)
def update(self):
"Update the visible items and draw."
self.model.filter()
self.view.update(self.model)
def wait_for_key_and_process(self):
"Wait for a key press and process it."
self.update()
key = self.view.get_key()
if key in (None, Keys.LEFT, Keys.RIGHT):
return
if key == Keys.ENTER:
self._clear_buffer()
elif key == Keys.ESCAPE:
self.model.search_text = ""
self.model.kb_buffer = ""
elif key == Keys.BACKSPACE:
self._clear_buffer(1)
elif key == Keys.UP:
self.view.change_pointer(-1)
elif key == Keys.DOWN:
self.view.change_pointer(1)
else:
self.model.kb_buffer += key
for key, value in self.commands.iteritems():
regex = re.compile(r'\A' + key + r'\Z')
match = regex.match(self.model.kb_buffer)
if match is not None:
value()
break
if len(self.model.kb_buffer) == 0 or self.model.kb_buffer[0] != "/":
self._clear_buffer()
def close(self):
#.........这里部分代码省略.........