A Python-native UI kit for creating interactive web frontends with a fluent API.
Project description
Webei UI Kit (Python)
webei is a revolutionary UI kit that allows you to design and build beautiful, modern web frontends entirely within Python. Forget about switching between HTML, CSS, and JavaScript. Describe your UI with simple, human-readable Python code, and webei will generate the necessary HTML and scoped CSS for you.
This new version focuses on ultimate flexibility and a magical, DSL-like experience.
Features
- Python-Native: Design UIs using Python objects and functions. No HTML/CSS required.
- Ultimate Flexibility: Style any standard HTML element with any CSS property, directly from Python.
- Human-Readable: Use intuitive arguments like
font_size="2rem"orshadow="large". - Component-Based: Comes with helpful pre-styled components like
CardandButton, or build your own fromdivs. - Scoped Styles: The engine automatically generates scoped CSS, so you don't have to worry about class name conflicts.
- Magic Activation: A simple
act()call injects all the necessary tools into your environment.
Installation
(This package is not on PyPI yet. To install locally for development:)
# Run this from the webei/pip directory
pip install -e .
How to Use
The new webei is incredibly simple.
-
Activate Webei: Call
act()at the top of your script. This magically makes all the component functions (p,c,div,h1, etc.) available. -
Build Your UI: Compose your UI by calling and nesting component functions. A
p()(Page) component is usually your root. -
Render: Call the
.render()method on your root component to generate the final HTML document.
Here's a minimal example with Flask:
from flask import Flask
from webei import act
# 1. Activate the Webei magic!
act()
app = Flask(__name__)
@app.route('/')
def home():
# 2. Build the UI entirely in Python
my_ui = p( # p is an alias for Page
div(
h1("Hello from Webei!", text_align="center"),
c( # c is an alias for Card
para("This is a card component."),
shadow="large",
margin_top="20px"
),
padding="2rem"
)
)
# 3. Render the UI to an HTML string
return my_ui.render()
if __name__ == '__main__':
app.run(debug=True)
Available Components & Tags
After calling act(), you have access to:
- High-Level Components:
Page,Card,Button,Text. - Aliases:
p(forPage),c(forCard). - Standard HTML Tags:
div,h1-h6,a,img,span,section,header,footer,nav,ul,li,form,input,textarea, and more.pis aliased toparato avoid conflict with thePagealias.
Styling
Style any element by passing keyword arguments. webei automatically converts them to CSS.
div(
"I'm a styled div!",
background_color="#eef",
border_left="5px solid #aae",
padding="20px",
font_family="monospace"
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file webei-0.2.0.tar.gz.
File metadata
- Download URL: webei-0.2.0.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe7f0ec239971eb98775075d397f484c4f16b496062a3788a0f5360395766de8
|
|
| MD5 |
ffd7c61d2acf2228775e6b0b4a93c82c
|
|
| BLAKE2b-256 |
9f145b5c726afd9a766ca0d47181632646092d15451f0db9e9d6a9e7ce2ec52e
|
File details
Details for the file webei-0.2.0-py3-none-any.whl.
File metadata
- Download URL: webei-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab09959ad9c9ca898b8f8655c50fc430bf11194ad944dc776f5e05b1b12bfd2c
|
|
| MD5 |
c7e072c6c37ba4ee919b18ae60c5b903
|
|
| BLAKE2b-256 |
d1d08855a114ae68214a00337b998acd6f141c47cef20573e3bae002d6351c0b
|