blo
blockkit
pypi i blockkit
blo

blockkit

A fast way to build Block Kit interfaces in Python

by ryche

1.5.2 (see all)License:MIT
pypi i blockkit
Readme

Screenshot

Build status PyPI version Downloads


Blockkit is a Python library for building UI interfaces for Slack apps. It allows you to compose the interface from Python classes, so you type less, and your code becomes more maintainable.

Blockkit performs validation at runtime and provides user-friendly errors when data is invalid.

Generate

You don't even need to write code yourself. Go to blockkit-generator.com paste your JSON payload from Block Kit Builder and get corresponding Python code!

Screenshot

Installation

pip install blockkit

Usage

Start with one of the Home, Modal, or Message surface classes and follow the structure as you would follow it in JSON.

The library supports all types of surfaces, blocks, block elements, and composition objects Slack provides.

Once UI is ready, call the build() method to render components to dictionary:

from blockkit import Section, MarkdownText

Section(text=MarkdownText(text="hello world")).build()

{"type": "section", "text": {"text": "hello world", "type": "mrkdwn"}}

Here's the list of types of components and corresponding classes:

Surfaces

TypeClass
homeHome
modalModal
Message
workflow_stepWorkflowStep

Blocks

TypeClass
actionsActions
contextContext
dividerDivider
headerHeader
imageImageBlock
inputInput
sectionSection

Block elements

TypeClass
buttonButton
checkboxesCheckboxes
datepickerDatePicker
typeImage
multi_static_selectMultiStaticSelect
multi_users_selectMultiUsersSelect
multi_channels_selectMultiChannelsSelect
multi_conversations_selectMultiConversationsSelect
multi_external_selectMultiExternalSelect
overflowOverflow
plain_text_inputPlainTextInput
radio_buttonsRadioButtons
static_selectStaticSelect
users_selectUsersSelect
channels_selectChannelsSelect
conversations_selectConversationsSelect
external_selectExternalSelect
timepickerTimepicker

Composition objects

TypeClass
plain_textPlainText
mrkdwnMarkdownText
Confirm
PlainOption
MarkdownOption
OptionGroup
Filter
DispatchActionConfig

Contributing

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

Please make sure to update tests as appropriate.

License

MIT

VersionTagPublished
1.5.2
4mos ago
1.5.1
7mos ago
1.5.0
1yr ago
1.4.0
1yr ago
No alternatives found
No tutorials found
Add a tutorial
No dependencies found

Rate & Review

100
No reviews found
Be the first to rate