UICord
A UI helper library for pycord that makes Discord's Components V2 simple to work with.
Features
- Clean wrappers around every Components V2 primitive (Button, Select, Container, Section, MediaGallery, …)
ViewandModalsubclasses with built-in owner-checking and auto-reload@interactiondecorator with automatic error reporting to developersUIString- astrsubclass with pluggable i18n viastate.translator_functionlang=keyword onViewandModalfor per-instance translations- Graceful pycord 2.7 / 2.8 compatibility shims (
MediaGalleryItem,Checkbox,CheckboxGroup)
UIL
- Allows users to write UIs using a builtin language.
- Free of hassle using hoisting and multiline lambdas.
Example:
@home(){
elements = []
elements.append(
ActionRow(
Button(
text: "Click me",
emoji: null,
gid: "HelloBTN"
),
Button(
text: "Dont click me",
emoji: null,
gid: "Dont"
)
)
)
HelloBTN::interact(i) => {
await i.respond(
"You clicked me!"
)
}
@async why(i){
await i.response.edit_message(
view: other.warning(prof, uid)
)
}
Dont.attach(why)
-> View(
elements,
uid: uid
)
}
Generated equivalent
def home(prof,uid,page):
elements=[]
HelloBTN=Button(text='Click me',emoji=null)
Dont=Button(text='Dont click me',emoji=null)
elements.append(ActionRow(HelloBTN,Dont))
async def lambda_0(i):
await i.respond('You clicked me!')
HelloBTN.interact=lambda_0
async def why(i):
await i.response.edit_message(view=other.warning(prof,uid))
Dont.attach(why)
return View(elements,uid=uid)
- UI management using
uil.load_uis
import uicord.uil as uil
uil.load_uis("./my_uis")
print(uicord.state.uis) # will have every file you have in your ui folder as modules.
- Single File UI Testing with
python -m uicord.uil examples/test.uil
Installation
pip install uicord
Requires pycord ≥ 2.7.
For Checkbox / CheckboxGroup support, use pycord ≥ 2.8.
Quick Start
import discord
from discord.ext import commands
import uicord
bot = commands.Bot(command_prefix="!")
@bot.slash_command()
async def demo(ctx):
view = uicord.View(owner=ctx.author.id)
btn = uicord.Button("Click me!", color=uicord.Colors.Blue)
view.add(ActionRow(btn))
@uicord.interaction(component=btn)
async def on_click(ictx):
await ictx.respond("You clicked it!", ephemeral=True)
await ctx.respond("Here you go:", view=view)
bot.run("TOKEN")
Internationalisation / Localisation
from uicord import state, UIString, View
# Plug in any translation backend
state.translator_function = lambda text, lang: my_i18n(text, lang)
# Translate at construction time
greeting = UIString("hello.world", lang="fr")
# Or let the View handle it - view._("key") returns a UIString in view.lang
view = View(lang="ja")
label = view._("btn.confirm") # → translated to Japanese
Components at a Glance
| Class | Description |
|---|---|
View |
Main component container with owner-check and reload |
Modal |
Input/output modal with label helpers |
Button |
Interactable button |
Toggle |
Stateful on/off button |
RadioButtons |
Radio-button group |
RadioButtonOption |
Option inside "Radio buttons" component |
Choices |
Select / drop-down menu |
ActionRow |
Manual row layout |
Container |
Component container |
Section |
Section block (pycord ≥ 2.7) |
Separator |
Visual divider |
Thumbnail |
Inline thumbnail |
MediaGallery |
Media gallery block (pycord ≥ 2.7) |
MediaGalleryItem |
Item inside a MediaGallery (pycord ≥ 2.7) |
Text |
Text display |
GridItem |
Item inside a Grid |
Grid |
Grid display |
Checkbox |
Single checkbox (pycord ≥ 2.8) |
CheckboxGroup |
Group of checkboxes (pycord ≥ 2.8) |
UIString |
Translatable string subclass |
Full API reference → uicord.readthedocs.io
Contributing
This project genuinely needs contributors. Bug reports, feature requests, and pull requests are all appreciated.
Originally made for you and the community by H1387Lmao ♥ - open-source, no license. Please keep it that way.
Metadata
Release files for uicord 5.1.0
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 | |
|---|---|---|---|---|
| uicord-5.1.0.tar.gz | 29.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| uicord-5.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 65.0 kB
Release files / uicord-5.1.0.tar.gz
| Download URL | uicord-5.1.0.tar.gz |
|---|---|
| Size | 29.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
82840b58a29ef278863818120b8aeca0821fd1c6ed502faa33b2ac9de8efbe71
|
|
BLAKE2b-256 checksum How to use checksums |
e2a790ab96940bbe2782ec34a9e871b199b8cffd3c40ae8ddb1ddd71d6d80d7e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.12.1.2 requests/2.32.5 setuptools/81.0.0 requests-toolbelt/1.0.0 tqdm/4.67.3 CPython/3.13.12
|
Release files / uicord-5.1.0-py3-none-any.whl
| Download URL | uicord-5.1.0-py3-none-any.whl |
|---|---|
| Size | 35.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
593fbb836937097a7bda7bf6dd23a9b7dda7b19eb2b12b5acbbf5daf697abb19
|
|
BLAKE2b-256 checksum How to use checksums |
9f8194f8bea7ffa1c63bd47a0e6c12b7c0afb82e41a4a28b0603b72e1f31066e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.12.1.2 requests/2.32.5 setuptools/81.0.0 requests-toolbelt/1.0.0 tqdm/4.67.3 CPython/3.13.12
|
Security for uicord 5.1.0
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.