PySinglSlider
PySinglSlider is a customizable, simple single slider widget built with Pygame. Designed for quick setup and theming, it lets you add an interactive slider for Pygame applications that need fine-grained control over a value range.
Features
- Easily customizable for different themes and styles.
- Supports adjustable value ranges.
- Includes event listening for smooth handling of slider interactions.
- Simple integration into any Pygame-based project.
Installation
Install PySinglSlider via PyPI:
pip install py_singl_slider
Getting Started
Importing and Setting Up the Slider
To integrate PySinglSlider into your Pygame project, follow these steps:
- Import
PySinglSliderfrompy_singl_sliderin your Pygame script. (see example down below) - Initialize the slider with optional parameters such as position, value range, initial value, and theme settings.
- Handle events and render the slider in your game loop.
Example Usage
Here's a basic example to get started:
import pygame
import py_singl_slider
pygame.init()
screen = pygame.display.set_mode((800, 600))
clock = pygame.time.Clock()
# Create slider
slider = py_singl_slider.PySinglSlider(x=100, y=250, min_value=0, max_value=100, initial_value=50)
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# Pass events to the slider
slider.listen_event(event)
# Clear the screen
screen.fill((255, 255, 255))
# Render the slider
slider.render(screen)
# Display the current slider value
font = pygame.font.Font(None, 36)
value_text = font.render(f"Value: {slider.value:.2f}", True, (0, 0, 0))
screen.blit(value_text, (100, 400))
pygame.display.flip()
clock.tick(30)
pygame.quit()
Parameters
x(int): X-coordinate for slider position.y(int): Y-coordinate for slider position.min_value(int): Minimum value of the slider range.max_value(int): Maximum value of the slider range.initial_value(int): Starting value of the slider.theme_name(str): Name of the theme folder containing assets (images for handler, bar, etc.).theme_path(str, optional): Custom path to the theme directory if assets are not located in the default theme folder.
Documentation
Methods
load_image(image_name, theme_name, theme_folder_path=None)
Loads an image from the specified theme directory.
get_rect()
Returns the Pygame rectangle (Rect) of the slider bar.
listen_event(event)
Listens to and handles mouse or touch events for updating the slider’s handler position.
get_current_value()
Calculates and returns the slider's current value based on handler position.
render(screen)
Renders the slider's components (bar, handler) on the specified screen.
Asset Customization
To customize the slider's appearance, you can create new images for the slider's handler and bar components in a folder with your chosen theme_name. Place this folder in the theme directory or specify the path using theme_path.
Example Theme Folder Structure
project_root/
├── theme/
│ ├── default_theme/
│ │ ├── handler.png
│ │ ├── bar_center.png
│ │ ├── bar_corner.png
│ └── custom_theme/
│ ├── handler.png
│ ├── bar_center.png
│ ├── bar_corner.png
└── main.py
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Enjoy using PySinglSlider! Contributions, bug reports, and suggestions are welcome.
Metadata
Release files for py-singl-slider 1.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| py_singl_slider-1.0.7.tar.gz | 7.2 kB | Without provenance | Details for py_singl_slider-1.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| py_singl_slider-1.0.7-py3-none-any.whl | Python 3 | none | any | Details for py_singl_slider-1.0.7-py3-none-any.whl |
Total release size: 14.1 kB
Release files / py_singl_slider-1.0.7.tar.gz
| Download URL | py_singl_slider-1.0.7.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b1b0de7115520d8727c8803819f32ad259709116a498a689014f13152374719c
|
|
BLAKE2b-256 checksum How to use checksums |
0410f3a772db1012b82dc15750f03a1e0c97a7cdc63389652e3651a298739f9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / py_singl_slider-1.0.7-py3-none-any.whl
| Download URL | py_singl_slider-1.0.7-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8c34168c9e63169f11d1c6db956ee31a9cc4abc9ce742f8174f83c5f3e81b3e2
|
|
BLAKE2b-256 checksum How to use checksums |
f641b41aa4e404b11f58ff337a063776686618be806744dbdc13e2a9155d80b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Security for py-singl-slider 1.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.