libtcod / python-tcod

A high-performance Python port of libtcod. Includes the libtcodpy module for backwards compatibility with older projects.
BSD 2-Clause "Simplified" License
413 stars 36 forks source link

tcod.context API does not display anything #93

Closed akemn closed 4 years ago

akemn commented 4 years ago

On macOS 10.15.4, attempting to run a minimal "hello world" using the new tcod.context API does not yield any console.

To reproduce, attempt to run:

import tcod
context = tcod.context.new_terminal(30, 30, title='test')

This will start up a bouncing Python rocket icon in the dock, but nothing else happens. Continue with:

console = tcod.Console(*context.recommended_console_size())
while True:
    # Display the console.
    console.clear()
    console.print(0, 0, "Hello World")
    context.present(console)

And still nothing happens. The Python rocket icon continues bouncing and must be force quit.

HexDecimal commented 4 years ago

I don't have a Mac to test with. Does tcod.context.new_window have the same issue? And does providing a tileset for the context change anything?

HexDecimal commented 4 years ago

Other things to check: Does tcod.console_init_root open a window correctly? And does adding event handling make the window work correctly:

import tcod
context = tcod.context.new_terminal(30, 30, title='test')
console = tcod.Console(*context.recommended_console_size())
while True:
    # Display the console.
    console.clear()
    console.print(0, 0, "Hello World")
    context.present(console)
    for event in tcod.event.wait():
        if event.type == "QUIT":
            raise SystemExit()
akemn commented 4 years ago

And does adding event handling make the window work correctly:

Yep, this was the issue. Added event handling and now it works correctly. Apologies! Same behavior with console_init_root: event handling required.

HexDecimal commented 4 years ago

No problem. I'll try to keep this in mind in case anyone else has the same issue.