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
Apache License 2.0
3.61k stars 238 forks source link

Asciimatics doesn't print anything. #357

Closed xzripper closed 2 years ago

xzripper commented 2 years ago

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):

Additional context Please help!

peterbrittain commented 2 years ago

You haven't created a Scene and then told the screen to play it. Take a look at https://github.com/peterbrittain/asciimatics/blob/31b3fe579af6ef08bcd8e01e33aeaf8d46805353/samples/contact_list.py#L175-L180

xzripper commented 2 years ago

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

xzripper commented 2 years ago
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!