Windows Curses Support

2.4.2 · active · verified Thu Apr 16

The `windows-curses` library provides a compatible implementation of the standard Python `curses` module for Microsoft Windows environments. It enables the creation of text-based user interfaces (TUIs) on Windows, bridging the gap as the native `curses` module is Unix-only. Currently at version 2.4.2, it sees active development with regular updates for new Python versions.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates the basic setup and use of `windows-curses`. It initializes the curses environment, displays a simple 'Hello World' message, waits for a key press, and then cleans up. The `curses.wrapper` function is used for robust initialization and cleanup.

import curses
from curses import wrapper

def main(stdscr):
    # Clear screen
    stdscr.clear()

    # Display a simple message
    stdscr.addstr(0, 0, "Hello from windows-curses!")
    stdscr.addstr(1, 0, "Press any key to exit.")

    # Refresh the screen to show changes
    stdscr.refresh()

    # Wait for user input
    stdscr.getch()

if __name__ == '__main__':
    wrapper(main)

view raw JSON →