Skip to main content

A window and UI library based on tkinter.

Project description

InGame 🎮

InGame is a lightweight Python library designed to simplify making amazing UIs within a basic GUI window using tkinter. It enables developers to easily register and trigger events based on key presses with clean, decorator-based syntax.


✨ Features

  • ✅ Decorator-based event binding
  • ✅ Enum-based key recognition (A–Z, arrows, Enter, Escape, etc.)
  • ✅ Clean and extensible architecture
  • ✅ Simple GUI rendering using tkinter

🚀 Getting Started

🔧 Installation

Use pip install ingame to install the project.


🧠 Usage Example

from ingame.core import InGame, Screen, EventType
from ingame.objects import Text, Button, Input

app = InGame()

@app.event(type=EventType.Key.A)
def handle_a():
    print("Key A pressed!")

@app.event(type=EventType.Key.ESCAPE)
def handle_escape():
    print("Escape pressed!")
    screen.quit()

screen = Screen(app, title="My InGame App")

screen.set_resize(True, True)

hello_text = Text(screen, text="Hello!")
Button(screen, text="Click me", command=hello_text.destroy)

ht_input = Input(screen, packargs={"pady": 10})

def ht_click() -> None:
    print(ht_input.get())

Button(screen, text="Print input value", command=ht_click, packargs={"pady": 10})

screen.show()

🎮 Supported Keys

Many keys are supported via EventType.Key, including:

  • A–Z
  • Arrow keys: UP, DOWN, LEFT, RIGHT
  • ENTER, ESCAPE, BACKSPACE

📦 Components

InGame

Handles registering and triggering events:

  • @event(type: EventType.Key): Registers a function for a specific key event.
  • trigger_event(type): Manually triggers an event.

Simple tkinter window with key event binding:

  • set_resize(width: bool, height: bool): Sets if the window's width and height can be resized.
  • show(): Opens the window and starts listening for key presses.
  • after(ms: int, func: FunctionType): Runs a function after a specified amount if milliseconds.
  • quit(): Closes the window.

⚠️ Exceptions

  • InGameException: Raised for invalid usage such as missing event type or unregistered keys.

🛠️ Development Notes

Written in Python 3.10+ Uses tkinter, Enum, abc, and inspect.


📄 License

InGame is licensed under the MIT License


❤️ Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you’d like to change.


👤 Author

Made by Natuworkguy

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

ingame-0.4.3.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

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

ingame-0.4.3-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file ingame-0.4.3.tar.gz.

File metadata

  • Download URL: ingame-0.4.3.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ingame-0.4.3.tar.gz
Algorithm Hash digest
SHA256 546c32cc9d97d25d4cbd36d68d3515b30e5a47e4531055b7264f5f0b67b5cdd7
MD5 4d7cdb4230593961251dcbe5d80988a9
BLAKE2b-256 806d7fb076ea8b480b5b08611c3c16cc2dc1d879f628854e35fbfa0f4add6c59

See more details on using hashes here.

File details

Details for the file ingame-0.4.3-py3-none-any.whl.

File metadata

  • Download URL: ingame-0.4.3-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ingame-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 166f8dd28e7168820ae2c979a3963963c0b8944181185160df1b66b59b7001b1
MD5 49669c3181a78ba96b070384264c4c99
BLAKE2b-256 55c43c97d07202453327ec32928e679fe78847c431856c863e2034ad5f5b102f

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