Skip to main content

slackuiblocks - Simplify Slack UI Block Creation with Python Classes

PyPI Version License

slackuiblocks is a Python library that provides an intuitive and elegant way to create Slack UI blocks using Python classes instead of dealing with complex JSON structures. With this library, you can easily craft interactive and visually appealing messages for your Slack channels or direct messages.

Features

  • Simplified Syntax: Define Slack UI blocks using Python classes, making it easier to structure your messages.
  • Interactive Elements: Create buttons, menus, and other interactive components effortlessly.
  • Customization: Customize the appearance and behavior of UI elements using Python attributes.
  • Well-Organized: Maintain a clear and organized codebase by encapsulating UI elements within classes.

Installation

You can install slackuiblocks using pip:

pip install slackuiblocks

Usage Example

Here's a simple example of how you can use slackuiblocks to create a message with interactive buttons:

from slack_sdk import WebClient
from slackuiblocks import Section, MarkdownText, Datepicker, PlainText

message = Blocks(
    blocks=[
        Section(
            text=MarkdownText(
                text=(
                    "*Sally* has requested you set the deadline for the Nano "
                    "launch project"
                )
            ),
            accessory=Datepicker(
                action_id="datepicker123",
                initial_date="1990-04-28",
                placeholder=PlainText(text="Select a date"),
            ),
        )
    ]
)

# Get the JSON representation of the block
block_json = message.dict(exclude_none=True)

# Use block_json in your Slack API request
channel = "your channel id"
try:
    client.chat_postMessage(
        channel=channel,
        text="message",
        blocks=block_json.get("blocks"),
    )
except Exception as e:
    print(e)

For more complex interactions, you can create menus, input fields, and more using Python classes just like the example above.

Documentation

For detailed usage instructions, examples, and a comprehensive list of available UI elements, refer to the Documentation.

Contributing

Contributions are welcome! To contribute to slackuiblocks, follow the guidelines outlined in CONTRIBUTING.md.

License

This project is licensed under the MIT License.

Metadata

Release files for slackuiblocks 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for slackuiblocks 0.0.7
File Size Uploaded Provenance Actions
slackuiblocks-0.0.7.tar.gz 8.9 kB Without provenance Details for slackuiblocks-0.0.7.tar.gz

Release files / slackuiblocks-0.0.7.tar.gz

Download URL slackuiblocks-0.0.7.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
05a4361d4adb409c7630e117a9224ad17b4696ad028cc2afafb4c0910c872c6e
BLAKE2b-256 checksum
How to use checksums
6333664eb53c1d01f6b178b6e76a74102200ed9a408a1579b0212a876207e989
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Security for slackuiblocks 0.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.

Release history Release notifications | RSS feed

This release

0.0.7 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page