Skip to main content

A custom Tkinter-Pygame module.

Project description

tkpygame

tkpygame is a Python package that combines Tkinter and Pygame functionality to enable enhanced GUI components and graphics rendering within Python applications. The package provides pre-built components, utilities, and color formatting options to facilitate a streamlined development experience.

Features

  • Custom GUI Components: Easily use components like buttons, dropdowns, input fields, and more with additional customization.
  • Base64 Icon Handling: Set application icons from base64-encoded images.
  • Pygame Integration: Allows for creating, rendering, and managing Pygame components within a Tkinter environment.
  • Utilities: Provides utilities for layout management, color formatting, and canvas updates.

Installation

You can install tkpygame via pip:

pip install tkpygame

Make sure you have Python 3.6 or later.

Dependencies

tkpygame requires the following external libraries, which are installed automatically with pip:

  • pygame: Used for graphics rendering.
  • Pillow: Used for handling images, especially for loading and converting images in base64 format.

Usage

Here's a quick example to get you started. This assumes you have installed tkpygame and want to use components from the jiggleifymodules package.

Example

from jiggleifymodules import Canvas, Button, Dropdown, InputField
import pygame

# Initialize pygame and Tkinter
pygame.init()

# Create and customize a Tkinter canvas with Pygame integration
canvas = Canvas(width=400, height=300)
button = Button(text="Click Me")
dropdown = Dropdown(options=["Option 1", "Option 2"])
input_field = InputField(placeholder="Type here...")

# Example function to set an icon from a base64 string
base64_icon = "iVBORw0KGgoAAAANSUhEUgAAAAUA..."  # Example base64 string
set_icon_from_base64(base64_icon)

Components Overview

  • Canvas: A Tkinter canvas with added methods for positioning and rendering Pygame visuals.
  • Button: A customizable button component with text and styling options.
  • Dropdown: A dropdown selection component.
  • InputField: A text input field with a placeholder.
  • Label: A label component with color and font styling.
  • Listbox and ListboxItem: Components for displaying lists of items.
  • Popup: A modal popup component for displaying messages or custom content.
  • ImageButton: A button component that uses an image as its icon.

Utility Functions

  • set_icon_from_base64(base64_string): Sets the application icon using a base64-encoded image string.
  • print_colored(text, color): Prints text to the terminal with ANSI color codes.

Layout Utilities

  • update_canvas_rect(canvas): Updates canvas dimensions based on dynamic size attributes.
  • update_rect(obj): Updates an object’s dimensions and position based on its parent canvas properties.

Terminal Colors

The package provides the TerminalColors class with predefined color codes to enable colorful terminal output. Here’s an example:

from jiggleifymodules import TerminalColors, print_colored

print_colored("This is a warning message", TerminalColors.WARNING)
print_colored("This is an error message", TerminalColors.FAIL)

Contributing

Contributions are welcome! If you'd like to contribute, please fork the repository, make your changes, and submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.


This README.md provides an overview, installation instructions, usage examples, and detailed descriptions of your package's components and functions. Adjust the details based on your specific module functionality and include any additional examples as necessary.

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

tkpygame-0.1.0.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

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

tkpygame-0.1.0-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file tkpygame-0.1.0.tar.gz.

File metadata

  • Download URL: tkpygame-0.1.0.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for tkpygame-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dfeab032491172cbdfb2d91d75f2769d874a724acab4147a579a3412bdd44fcd
MD5 11556f7e143880b380e6cece0ab42edd
BLAKE2b-256 652c88bc1c1f36eb64dfcfc800dc14e5e2e35b14fe79914520ece9ca01187ad6

See more details on using hashes here.

File details

Details for the file tkpygame-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tkpygame-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for tkpygame-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 00e408b863b84276f37ef2dd3b9a3f568d0fb7394169ba478f04c1395c19fc52
MD5 6e2f04d7231ed3ec2b1f9a5296a7f1a3
BLAKE2b-256 28f9f7a28d8ac22f322ccbd42522054a0e8176c022b2848d30e43cd1d7f154b2

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