peterbrittain / asciimatics

A cross platform package to do curses-like operations, plus higher level APIs and widgets to create text UIs and ASCII art animations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Asciimatics doesn't print anything.

xzripper opened this issue · comments

commented

Describe the bug
If I run something, terminal screen just blink one time and script stop working.

To Reproduce

from asciimatics.widgets import Frame, Layout, Button
from asciimatics.screen import Screen 

def main(screen):
    frame = Frame(screen, 80, 20, has_border=False)
    layout = Layout([1, 1, 1, 1])
    frame.add_layout(layout)

    layout.add_widget(Button("Button 1", lambda: print("Button 1 pressed")), 0)


Screen.wrapper(main)

Expected behavior
It must create button.

Screenshots

I wrote there "python main.py"

System details (please complete the following information):

  • OS and version: Windows 10
  • Python version: 3.9.13
  • Python distribution: Python 3.9.13 (python -V)
  • Asciimatics version: 1.14.0

Additional context
Please help!

You haven't created a Scene and then told the screen to play it. Take a look at

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)

commented

how do i add to scenes my main function? i dont have any ListView, or ContactView..

commented
from asciimatics.widgets import Frame, Layout, Button
from asciimatics.screen import Screen
from asciimatics.scene import Scene

def main(screen):
    frame = Frame(screen, 80, 20, has_border=False)
    layout = Layout([1, 1, 1, 1])
    frame.add_layout(layout)

    layout.add_widget(Button("Button 1", lambda: print("Button 1 pressed")), 0)

    screen.play([Scene([frame])])


Screen.wrapper(main)

Solved. Thank!