Skip to main content

Help module for overlays and contextual help in Pygame

Project description

💡 help_core_pygame: Standalone Markdown Help Viewer (Pygame)

Spanish version: README_es.md

MIT License

🚀 Overview

help_core_pygame is a Python library designed to provide a highly portable and self-contained help viewer based only on Pygame.

It can render reduced Markdown text in a standalone window or directly onto any Pygame surface, without relying on heavyweight GUI frameworks.

Primary Use Case

Ideal for Pygame projects that need a professionally formatted help screen (headings, lists, code, basic styling), with full scroll support and event handling.
Help content is provided as Markdown text. Markdown support is intentionally limited but sufficient for structured, good-looking help screens.


📚 Documentation

Index of the complete project documentation: docs/INDEX_en.md


🧭 Examples launcher (main.py)

A launcher is provided in the project root to run the scripts under examples/.

Run

python3 main.py

Which scripts are listed

The launcher only lists scripts that match:

  1. Extension: must end with .py
  2. Path: the relative path must start with one of the prefixes in PATH_INCLUDE (a list defined in main.py)
  3. Header: the script must contain a Descripción breve: line in its header

This makes it possible to keep helper scripts in examples/ without listing them as demos.


✨ Highlights

  • No heavy dependencies: only Pygame.
  • Reduced Markdown support: headings (#), paragraphs, lists (-, 1.), inline code (`code`) and fenced code blocks (```).
  • Standalone mode: open_help_standalone opens a dedicated window with its own event loop.
  • Embedded mode: integrate HelpViewer into your own screen/surface and handle events via handle_event.
  • Smooth scrolling: mouse wheel and keyboard support (implementation details may vary by demo/style).
  • Scroll limit callback: on_scroll_limit can be used to trigger feedback (e.g., a sound) when reaching top/bottom.

📦 Installation

Option A) Install from PyPI (pending)

Note: this version is not published on PyPI yet.
Once published, this section will include the final pip install ... command.

Option B) Install from the repository (recommended for now)

Clone the repository and install in editable mode:

python3 -m venv .venv
. .venv/bin/activate
pip install -U pip
pip install -e .

You need pygame (it will be installed via declared dependencies if available, or install it manually if your environment requires it).


1) Standalone usage example

A complete demo is available at examples/demo_help_standalone.py.
Below is a minimal standalone usage example:

import pygame
from help_core_pygame import open_help_standalone

pygame.init()

try:
    MD_TEXT = open("my_help.md", encoding="utf-8").read()
except FileNotFoundError:
    MD_TEXT = "# Error\nHelp file not found."

try:
    beep_sound = pygame.mixer.Sound("beep_scroll.mp3")
except pygame.error:
    print("Warning: could not load 'beep_scroll.mp3'.")
    beep_sound = None


def beep_on_limit(where: str) -> None:
    """Called when the scroll limit is reached (top/bottom)."""
    print(f"Scroll limit reached: {where}")
    if beep_sound is not None:
        beep_sound.play()


open_help_standalone(
    md_text=MD_TEXT,
    title="My App Help",
    size=(1200, 900),
    wheel_step=48,
    kernel_bg=(222, 222, 222),
    on_scroll_limit=beep_on_limit,
    scroll_limit_cooldown_ms=300,
)

pygame.quit()

2) Overlay example (in your main window)

A complete demo is provided at examples/demo_help_overlay_beep.py.

In this mode the help viewer is displayed on top of your main window (overlay/modal). When you exit the help screen, your game continues normally.

For a map of examples and what each one validates, see: docs/OVERVIEW_es.md

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

help_core_pygame-0.1.2.tar.gz (282.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

help_core_pygame-0.1.2-py3-none-any.whl (300.7 kB view details)

Uploaded Python 3

File details

Details for the file help_core_pygame-0.1.2.tar.gz.

File metadata

  • Download URL: help_core_pygame-0.1.2.tar.gz
  • Upload date:
  • Size: 282.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for help_core_pygame-0.1.2.tar.gz
Algorithm Hash digest
SHA256 85767f33c695148e2ba648748c9b8071cad54dfa807883bcb96c3c771f482b4f
MD5 fd38674a5934a0d6aa16c3042a97be49
BLAKE2b-256 9cabd56c3d8bf93e7d97e263e574b2ca8b9050792f221b89a352a0538bafa512

See more details on using hashes here.

File details

Details for the file help_core_pygame-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for help_core_pygame-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 31272d2ee0eb71db80395323f9da9b25facd0c6a9e5020da7a56a167dc340290
MD5 6373b5194f8775247df50a080758aecb
BLAKE2b-256 0cb2bd679ffc67779ae0e6e72ba9fa6848bc8aeece9812e667cedde5824aa302

See more details on using hashes here.

Supported by

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