Skip to main content

Python bindings for the dos-like programming library

Project description

python-dos-like is a set of Python bindings for the dos-like programming library by Mattias Gustavsson.

https://github.com/cknave/python-dos-like/actions/workflows/testing.yml/badge.svg

Usage

pip install python-dos-like

python-dos-like can be used in the same way as dos-like by calling dos_like.start on your main function:

from random import randrange

import dos_like
from dos_like.dos import *


def main():
    setvideomode(videomode_320x200)

    while not shuttingdown():
        waitvbl()
        for _ in range(50):
            setcolor(randrange(256))
            line(randrange(320), randrange(200), randrange(320), randrange(200))
            setcolor(randrange(256))
            fillcircle(randrange(320), randrange(200), randrange(30))
            setcolor(randrange(256))
            circle(randrange(320), randrange(200), randrange(30))

dos_like.start(main)

You can also use python-dos-like in the Python REPL by calling dos_like.run_in_background:

>>> import dos_like
>>> from dos_like.dos import *
>>> dos_like.run_in_background(['-w'])
>>> cputs('hello world!')

Building

Building python-dos-like requires C development tools to be installed.

On Linux and macOS, the SDL2 and GLEW libraries are required.

If building from a git repository, you must update submodules to get the dos-like source.

git submodule update --init --recursive
$ python -mvenv .venv
$ . .venv/bin/activate
(.venv) $ pip install -e '.[dev]'
(.venv) $ coverage run -m unittest && coverage report

Several environment variables may be set to control compile-time options:

Environment variable

Default

Description

ALWAYS_UPDATE

1

Update the screen in the background. Set this to 0 to restore dos-like’s default behavior of pausing updates when the window loses focus.

CFLAGS

Extra compiler flags. Of note, -DNULL_PLATFORM is useful to build a library for headless build servers.

Limitations

This library has been tested on Linux and Windows. It builds on macOS, however running in the background raises an AppKit assertion. Building on WebAssembly should be a real challenge.

The lifecycle of graphics, music, and sound loaded from dos-like is not managed, and is likely leaking memory.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-dos-like-0.0.2.tar.gz (1.8 MB view hashes)

Uploaded Source

Built Distributions

python_dos_like-0.0.2-cp310-cp310-win_amd64.whl (1.3 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

python_dos_like-0.0.2-cp310-cp310-manylinux_2_28_x86_64.whl (2.4 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.28+ x86-64

python_dos_like-0.0.2-cp310-cp310-macosx_10_15_x86_64.whl (1.3 MB view hashes)

Uploaded CPython 3.10 macOS 10.15+ x86-64

python_dos_like-0.0.2-cp39-cp39-win_amd64.whl (1.3 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

python_dos_like-0.0.2-cp39-cp39-manylinux_2_28_x86_64.whl (2.4 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.28+ x86-64

python_dos_like-0.0.2-cp39-cp39-macosx_10_15_x86_64.whl (1.3 MB view hashes)

Uploaded CPython 3.9 macOS 10.15+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page