本文整理汇总了Python中asciimatics.screen.Screen.ctrl方法的典型用法代码示例。如果您正苦于以下问题:Python Screen.ctrl方法的具体用法?Python Screen.ctrl怎么用?Python Screen.ctrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类asciimatics.screen.Screen
的用法示例。
在下文中一共展示了Screen.ctrl方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_event
# 需要导入模块: from asciimatics.screen import Screen [as 别名]
# 或者: from asciimatics.screen.Screen import ctrl [as 别名]
def process_event(self, event):
# Do the key handling for this Frame.
if isinstance(event, KeyboardEvent):
if event.key_code in [ord('q'), ord('Q'), Screen.ctrl("c")]:
raise StopApplication("User quit")
# Now pass on to lower levels for normal handling of the event.
return super(DemoFrame, self).process_event(event)
示例2: test_ctrl
# 需要导入模块: from asciimatics.screen import Screen [as 别名]
# 或者: from asciimatics.screen.Screen import ctrl [as 别名]
def test_ctrl(self):
"""
Check that ctrl returns the right values.
"""
# Check standard alphabetical range
for i, char in enumerate(range(ord('@'), ord('Z'))):
self.assertEqual(Screen.ctrl(char), i)
self.assertEqual(Screen.ctrl(chr(char)), i)
self.assertEqual(Screen.ctrl(chr(char).lower()), i)
# Check last few options - which mostly aren't actually returned in
# Linux and so probably only of limited value, but what the heck!
for i, char in enumerate(["[", "\\", "]", "^", "_"]):
self.assertEqual(Screen.ctrl(char), i + 27)
# Check other things return None - pick boundaries for checks.
for char in ["?", "`", "\x7f"]:
self.assertIsNone(Screen.ctrl(char))
示例3: process_event
# 需要导入模块: from asciimatics.screen import Screen [as 别名]
# 或者: from asciimatics.screen.Screen import ctrl [as 别名]
def process_event(self, event):
# Do the key handling for this Frame.
if isinstance(event, KeyboardEvent):
if event.key_code in [ord('q'), ord('Q'), Screen.ctrl("c")]:
raise StopApplication("User quit")
elif event.key_code in [ord("r"), ord("R")]:
self._reverse = not self._reverse
elif event.key_code == ord("<"):
self._sort = max(0, self._sort - 1)
elif event.key_code == ord(">"):
self._sort = min(7, self._sort + 1)
# Force a refresh for improved responsiveness
self._last_frame = 0
# Now pass on to lower levels for normal handling of the event.
return super(DemoFrame, self).process_event(event)