Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Scene 2 - Chase ghosts after a power pill
scenes.append(EatingScene(screen))
# Scene 3 - Thanks...
effects = [
Print(screen, FigletText("Thank you,"), screen.height // 3 - 3,
colour=Screen.COLOUR_RED),
Print(screen,
StaticRenderer(images=[namco]),
screen.height * 2 // 3 - 2,
colour=Screen.COLOUR_RED),
Print(screen,
StaticRenderer(images=["< Press X to exit. >"]),
screen.height - 1)
]
scenes.append(Scene(effects, 0))
screen.play(scenes, stop_on_resize=True, repeat=False)
effects = [
Cycle(
screen,
FigletText("ASCIIMATICS", font='big'),
screen.height // 2 - 8,
stop_frame=100),
Cycle(
screen,
FigletText("ROCKS!", font='big'),
screen.height // 2 + 3,
stop_frame=100),
Stars(screen, (screen.width + screen.height) // 2, stop_frame=100),
DropScreen(screen, 100, start_frame=100)
]
scenes.append(Scene(effects, 200))
effects = [
Print(screen,
SpeechBubble("Press 'X' to exit."), screen.height // 2 - 1, attr=Screen.A_BOLD)
]
scenes.append(Scene(effects, -1))
screen.play(scenes, stop_on_resize=True)
Matrix(screen, stop_frame=200),
Mirage(
screen,
FigletText("Asciimatics"),
screen.height // 2 - 3,
Screen.COLOUR_GREEN,
start_frame=100,
stop_frame=200),
Wipe(screen, start_frame=150),
Cycle(
screen,
FigletText("Asciimatics"),
screen.height // 2 - 3,
start_frame=200)
]
scenes.append(Scene(effects, 250, clear=False))
effects = [
BannerText(
screen,
Rainbow(screen, FigletText(
"Reliving the 80s in glorious ASCII text...", font='slant')),
screen.height // 2 - 3,
Screen.COLOUR_GREEN)
]
scenes.append(Scene(effects))
effects = [
Mirage(
screen,
FigletText("Conceived and"),
screen.height,
def demo(screen, scene):
screen.play([Scene([
Background(screen),
MainWindow(screen)
], -1)], stop_on_resize=True, start_scene=scene, )
# Now check that we can move to named scenes.
test_effect1 = MockEffect(stop=False, next_scene="B")
test_effect2 = MockEffect(count=5)
screen.play([
Scene([test_effect1], 15, name="A"),
Scene([test_effect2], 0, name="B")])
self.assertTrue(test_effect1.update_called)
self.assertTrue(test_effect2.update_called)
# Now check that bad names cause an exception.
with self.assertRaises(RuntimeError):
test_effect1 = MockEffect(stop=False, next_scene="C")
test_effect2 = MockEffect(count=5)
screen.play([
Scene([test_effect1], 15, name="A"),
Scene([test_effect2], 0, name="B")])
self.assertTrue(test_effect1.update_called)
self.assertFalse(test_effect2.update_called)
# Now check that play stops at the end when repeat=False
test_effect1 = MockEffect(stop=False)
scene1 = Scene([test_effect1], 5, name="1")
screen.play([scene1], repeat=False)
self.assertTrue(test_effect1.update_called)
scene2 = Scene([], 10)
canvas = Canvas(screen, 10, 40, 0, 0)
# Check that pop-up dialogs get copied to the new Scene
form = PopUpDialog(
canvas, "Message", ["Yes", "No"], test_on_click, has_shadow=True)
form.register_scene(scene)
form.clone(canvas, scene2)
self.assertEqual(len(scene2.effects), 1)
self.assertEqual(scene2.effects[0]._text, "Message")
self.assertEqual(scene2.effects[0]._buttons, ["Yes", "No"])
# Check that normal Frame data gets copied to the new Scene.
frame = TestFrame(canvas)
frame2 = TestFrame(canvas)
scene2 = Scene([frame2], 10)
frame.register_scene(scene)
frame2.register_scene(scene)
frame.data = {"TA": ["something"]}
frame2.data = {}
self.assertEqual(frame2.data, {})
self.assertNotEqual(frame2.data, frame.data)
frame.clone(canvas, scene2)
self.assertEqual(frame2.data, frame.data)
def internal_checks(screen):
# Since the Screen draws things, there's not too much we can do
# to genuinely verify this without verifying all Scene and Effect
# function too. Just play a dummy Effect for now.
test_effect = MockEffect()
screen.play([Scene([test_effect], 0)])
self.assertTrue(test_effect.stop_called)
self.assertTrue(test_effect.reset_called)
# Now check that the desired duration is used.
test_effect = MockEffect(count=6)
screen.play([Scene([test_effect], 15)])
self.assertFalse(test_effect.stop_called)
self.assertTrue(test_effect.reset_called)
# Now check that delete_count works.
test_effect = MockEffect(count=6)
test_effect2 = MockEffect(delete_count=3)
scene = Scene([test_effect, test_effect2], 15)
self.assertEqual(len(scene.effects), 2)
screen.play([scene])
self.assertEqual(len(scene.effects), 1)
def internal_checks(screen):
# First check that we can move between screens.
test_effect1 = MockEffect(stop=False)
test_effect2 = MockEffect(count=5)
screen.play([
Scene([test_effect1], 5),
Scene([test_effect2], 0)])
self.assertTrue(test_effect1.update_called)
self.assertTrue(test_effect2.update_called)
# Now check that we can start at the second scene.
test_effect1 = MockEffect(stop=False)
scene1 = Scene([test_effect1], 5, name="1")
test_effect2 = MockEffect(count=3)
scene2 = Scene([test_effect2], 0, name="2")
screen.play([scene1, scene2], start_scene=scene2)
self.assertFalse(test_effect1.update_called)
self.assertTrue(test_effect2.update_called)
# Now check that we can move to named scenes.
test_effect1 = MockEffect(stop=False, next_scene="B")
test_effect2 = MockEffect(count=5)
def test_clone(self):
"""
Check Frame cloning works.
"""
def test_on_click(selection):
raise NextScene(str(selection))
screen = MagicMock(spec=Screen, colours=8, unicode_aware=False)
scene = MagicMock(spec=Scene)
scene2 = Scene([], 10)
canvas = Canvas(screen, 10, 40, 0, 0)
# Check that pop-up dialogs get copied to the new Scene
form = PopUpDialog(
canvas, "Message", ["Yes", "No"], test_on_click, has_shadow=True)
form.register_scene(scene)
form.clone(canvas, scene2)
self.assertEqual(len(scene2.effects), 1)
self.assertEqual(scene2.effects[0]._text, "Message")
self.assertEqual(scene2.effects[0]._buttons, ["Yes", "No"])
# Check that normal Frame data gets copied to the new Scene.
frame = TestFrame(canvas)
frame2 = TestFrame(canvas)
scene2 = Scene([frame2], 10)
frame.register_scene(scene)
def demo(screen, scene):
scenes = [
Scene([ListView(screen, contacts)], -1, name="Main"),
Scene([ContactView(screen, contacts)], -1, name="Edit Contact")
]
screen.play(scenes, stop_on_resize=True, start_scene=scene, allow_int=True)