本文整理汇总了Python中asciimatics.screen.Screen.wrapper方法的典型用法代码示例。如果您正苦于以下问题:Python Screen.wrapper方法的具体用法?Python Screen.wrapper怎么用?Python Screen.wrapper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类asciimatics.screen.Screen
的用法示例。
在下文中一共展示了Screen.wrapper方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_wrapper
# 需要导入模块: from asciimatics.screen import Screen [as 别名]
# 或者: from asciimatics.screen.Screen import wrapper [as 别名]
def test_wrapper(self):
"""
Check that you can create a blank Screen.
"""
def internal_checks(screen):
# Check screen basically exists
self.assertIsNotNone(screen)
self.assertGreater(screen.width, 0)
self.assertGreater(screen.height, 0)
self.assertGreater(screen.colours, 0)
# Check that the Screen is cleared ready for use.
for x in range(screen.width):
for y in range(screen.height):
char, fg, attr, bg = screen.get_from(x, y)
self.assertEqual(char, ord(" "))
self.assertEqual(fg, Screen.COLOUR_WHITE)
self.assertEqual(attr, 0)
self.assertEqual(bg, Screen.COLOUR_BLACK)
Screen.wrapper(internal_checks)
示例2: test_print_and_get
# 需要导入模块: from asciimatics.screen import Screen [as 别名]
# 或者: from asciimatics.screen.Screen import wrapper [as 别名]
def test_print_and_get(self):
"""
Check that basic print_at and get_from work as expected.
"""
def internal_checks(screen):
for x in range(screen.width):
for y in range(15):
char = randint(0, 255)
fg = randint(0, Screen.COLOUR_WHITE)
bg = randint(0, Screen.COLOUR_WHITE)
attr = randint(0, Screen.A_UNDERLINE)
screen.print_at(chr(char), x, y, fg, attr, bg)
char2, fg2, attr2, bg2 = screen.get_from(x, y)
self.assertEqual(char, char2)
self.assertEqual(fg, fg2)
self.assertEqual(attr, attr2)
self.assertEqual(bg, bg2)
Screen.wrapper(
check_screen_and_canvas, height=15, arguments=[internal_checks])
示例3: test_visible
# 需要导入模块: from asciimatics.screen import Screen [as 别名]
# 或者: from asciimatics.screen.Screen import wrapper [as 别名]
def test_visible(self):
"""
Check that is_visible works as expected.
"""
def internal_checks(screen):
# Check some points that must always be visible
self.assertTrue(screen.is_visible(0, 0))
self.assertTrue(screen.is_visible(
screen.width - 1, screen.height - 1))
# Check some points that cannot be visible
self.assertFalse(screen.is_visible(-1, -1))
self.assertFalse(screen.is_visible(
screen.width, screen.height))
Screen.wrapper(
check_screen_and_canvas, height=15, arguments=[internal_checks])
示例4: test_scroll
# 需要导入模块: from asciimatics.screen import Screen [as 别名]
# 或者: from asciimatics.screen.Screen import wrapper [as 别名]
def test_scroll(self):
"""
Check that scrolling works as expected.
"""
def internal_checks(screen):
# New screen is not scrolled.
self.assertEqual(screen.start_line, 0)
# Scroll and check it has moved
screen.scroll()
self.assertEqual(screen.start_line, 1)
# Scroll to specific location and check it has moved
screen.scroll_to(0)
self.assertEqual(screen.start_line, 0)
Screen.wrapper(internal_checks, height=15)
示例5: test_putch_and_getch
# 需要导入模块: from asciimatics.screen import Screen [as 别名]
# 或者: from asciimatics.screen.Screen import wrapper [as 别名]
def test_putch_and_getch(self):
"""
Check deprecated features still work.
"""
def internal_checks(screen):
for x in range(screen.width):
for y in range(15):
char = randint(0, 255)
fg = randint(0, Screen.COLOUR_WHITE)
bg = randint(0, Screen.COLOUR_WHITE)
attr = randint(0, Screen.A_UNDERLINE)
screen.putch(chr(char), x, y, fg, attr, bg)
char2, fg2, attr2, bg2 = screen.getch(x, y)
self.assertEqual(char, char2)
self.assertEqual(fg, fg2)
self.assertEqual(attr, attr2)
self.assertEqual(bg, bg2)
Screen.wrapper(internal_checks, height=15)
示例6: test_refresh
# 需要导入模块: from asciimatics.screen import Screen [as 别名]
# 或者: from asciimatics.screen.Screen import wrapper [as 别名]
def test_refresh(self):
"""
Check that refresh works.
"""
def internal_checks(screen):
# Not much we can do here as refresh will draw to a screen we can't
# query. Check that we don't hit an Exception on refresh().
screen.print_at("Hello world!",
0, 0,
colour=Screen.COLOUR_CYAN,
attr=Screen.A_BOLD,
bg=Screen.COLOUR_BLUE)
screen.refresh()
Screen.wrapper(
check_screen_and_canvas, height=15, arguments=[internal_checks])
示例7: test_forced_update
# 需要导入模块: from asciimatics.screen import Screen [as 别名]
# 或者: from asciimatics.screen.Screen import wrapper [as 别名]
def test_forced_update(self):
"""
Check that forcing an update works as expected.
"""
def internal_checks(screen):
# First check that Effects are always drawn at Scene start
test_effect = MockEffect(count=101, stop_frame=101, frame_rate=100)
screen.set_scenes([Scene([test_effect], 0)])
screen.draw_next_frame()
self.assertTrue(test_effect.update_called)
# Now check that the Screen honours the long frame rate...
test_effect.update_called = False
for _ in range(90):
screen.draw_next_frame()
self.assertFalse(test_effect.update_called)
# Now check that the forced update works as expected.
screen.force_update()
screen.draw_next_frame()
self.assertTrue(test_effect.update_called)
Screen.wrapper(internal_checks, height=15)
示例8: test_scroll_redraw
# 需要导入模块: from asciimatics.screen import Screen [as 别名]
# 或者: from asciimatics.screen.Screen import wrapper [as 别名]
def test_scroll_redraw(self):
"""
Check that scrolling works with screen locations.
"""
def internal_checks(screen):
# New screen is not scrolled.
self.assertEqual(screen.start_line, 0)
# Scroll and check it has not moved
screen.print_at("Hello", 0, 1)
for i, c in enumerate("Hello"):
self.assertEqual(screen.get_from(i, 1)[0], ord(c))
screen.scroll()
for i, c in enumerate("Hello"):
self.assertEqual(screen.get_from(i, 1)[0], ord(c))
screen.refresh()
for i, c in enumerate("Hello"):
self.assertEqual(screen.get_from(i, 1)[0], ord(c))
Screen.wrapper(internal_checks)
示例9: test_unhandled_events
# 需要导入模块: from asciimatics.screen import Screen [as 别名]
# 或者: from asciimatics.screen.Screen import wrapper [as 别名]
def test_unhandled_events(self):
"""
Check that default handling of events works as documented.
"""
def internal_checks(screen):
# Check for exit
for char in ("X", "x", "Q", "q"):
with self.assertRaises(StopApplication):
event = KeyboardEvent(ord(char))
screen._unhandled_event_default(event)
for char in (" ", "\n"):
with self.assertRaises(NextScene):
event = KeyboardEvent(ord(char))
screen._unhandled_event_default(event)
Screen.wrapper(internal_checks, height=15)
示例10: test_signal
# 需要导入模块: from asciimatics.screen import Screen [as 别名]
# 或者: from asciimatics.screen.Screen import wrapper [as 别名]
def test_signal(self):
"""
Check that signals are restored after using _CursesScreen
"""
if sys.platform == "win32":
self.skipTest("Windows does not have signals.")
def dummy_signal_handler():
"""Dummy previous signal handler."""
pass
outer_state = _SignalState()
self.assertNotEqual(signal.getsignal(signal.SIGWINCH), dummy_signal_handler)
outer_state.set(signal.SIGWINCH, dummy_signal_handler)
self.assertEqual(signal.getsignal(signal.SIGWINCH), dummy_signal_handler)
Screen.wrapper(self.signal_check)
self.assertEqual(signal.getsignal(signal.SIGWINCH), dummy_signal_handler)
outer_state.restore()
self.assertNotEqual(signal.getsignal(signal.SIGWINCH), dummy_signal_handler)
示例11: load
# 需要导入模块: from asciimatics.screen import Screen [as 别名]
# 或者: from asciimatics.screen.Screen import wrapper [as 别名]
def load(self):
current_dapp = None
while True:
try:
#raise RunDapp
screen = Screen.wrapper(self.tui)
break
except ResizeScreenError as e:
#debug(); import pdb; pdb.set_trace()
# TODO make ResizeScreenError just raise NextScene
pass
except RunDapp:
print("switching to dapp...")
# load dapp from wherever it is
from dapp import Dapp
current_dapp = Dapp(screen, self.node)
except ExitDapp:
del(sys.modules['dapp'])
except ExitTuiError:
print("Shutting it all down...")
break
示例12: wrapper
# 需要导入模块: from asciimatics.screen import Screen [as 别名]
# 或者: from asciimatics.screen.Screen import wrapper [as 别名]
def wrapper(cls, func, watch=False):
if watch:
Screen.wrapper(func)
else:
func(display)
示例13: test_wrapper_return
# 需要导入模块: from asciimatics.screen import Screen [as 别名]
# 或者: from asciimatics.screen.Screen import wrapper [as 别名]
def test_wrapper_return(self):
"""
Check that you get the result back from the wrapped function.
"""
def internal_checks(_):
return True
self.assertTrue(Screen.wrapper(internal_checks))
示例14: test_limits
# 需要导入模块: from asciimatics.screen import Screen [as 别名]
# 或者: from asciimatics.screen.Screen import wrapper [as 别名]
def test_limits(self):
"""
Check that get_from and print_at limit checking works.
"""
def internal_checks(screen):
# Check we have some canvas dimensions
self.assertEqual(screen.dimensions[1], screen.width)
self.assertEqual(screen.dimensions[0], screen.height)
# Basic limit checking
self.assertIsNone(screen.get_from(-1, -1))
self.assertIsNone(screen.get_from(screen.width, screen.height))
# Printing off-screen should not fail, but do nothing.
screen.print_at("hello", 0, -1)
screen.print_at("hello", 0, screen.height)
# Printing across screen edge should crop.
screen.print_at("12345", -1, 0)
char, fg, _, bg = screen.get_from(0, 0)
self.assertEqual(char, ord("2"))
self.assertEqual(fg, Screen.COLOUR_WHITE)
self.assertEqual(bg, Screen.COLOUR_BLACK)
Screen.wrapper(
check_screen_and_canvas, height=15, arguments=[internal_checks])
示例15: test_centre
# 需要导入模块: from asciimatics.screen import Screen [as 别名]
# 或者: from asciimatics.screen.Screen import wrapper [as 别名]
def test_centre(self):
"""
Check that centre works as expected.
"""
def internal_checks(screen):
screen.centre("1234", 0)
char, fg, _, bg = screen.get_from((screen.width - 4) // 2, 0)
self.assertEqual(char, ord("1"))
self.assertEqual(fg, Screen.COLOUR_WHITE)
self.assertEqual(bg, Screen.COLOUR_BLACK)
Screen.wrapper(internal_checks, height=15)