Melid
Melid is a PyQt5 Library for Desktop Applications containing commonly used utils and advanced widget implementations in very simple forms.
Features
- Router
- State management
- Data binded widgets (Provider Widget)
- Hot-reload
- CSS Processor (TailwindCSS Syntax)
Install
$ pip install melid
Usage
With Builder Pattern (compose widgets with a Flutter-like pattern)
from PyQt5.QtCore import Qt
from melid.app import CreateApp
from melid.layout import Box, Direction
from melid.processors import CSSProcessor
from melid.router import Route, Router
from melid.utils import Size
from melid.widgets import Button, Input, InputType, Label
css = CSSProcessor(BASE_DIR.joinpath("examples/builder/style.css")).get
def IndexPage():
return Box(
Box(
[
Label("Click here to "),
Button(
"Login",
on_click=lambda: Router.navigate("/login"),
style=css("button", "border-radius: none;"),
),
],
style=css("py-5"),
alignment=Qt.AlignmentFlag.AlignCenter,
direction=Direction.ROW,
gap=5,
),
alignment=Qt.AlignmentFlag.AlignCenter,
style=css("py-5 my-5 border-gray"),
)
def LoginPage():
return Box(
Box(
[
Input(
placeholder="Username",
on_change=print,
style=css("input", "border-radius: none;"),
),
Input(
placeholder="Password",
on_change=print,
input_type=InputType.PASSWORD,
style=css("input", "border-radius: none;"),
),
Box(
[
Button(
"Login",
on_click=lambda: print("hello"),
style=css(
"button", "border-radius: none; border-right: none;"
),
),
Button(
"Go Back",
on_click=lambda: Router.navigate("/"),
style=css("button", "border-radius: none;"),
),
],
alignment=Qt.AlignmentFlag.AlignVCenter,
size=Size(minimum_width=400),
),
],
direction=Direction.COLUMN,
alignment=Qt.AlignmentFlag.AlignVCenter,
size=Size(minimum_width=400),
gap=20,
),
alignment=Qt.AlignmentFlag.AlignCenter,
)
if __name__ == "__main__":
CreateApp(
Router(
Route("/", IndexPage()),
Route("/login", LoginPage()),
),
).showMaximized().mount()
Styling
Melid comes with it's own implementation of tailwind and it is dependency free.
Due to the default limitations of PyQt5 stylesheet (QSS - CSS2), not all tailwind classes are supported. Also, for layout related styles (flex, grid, etc) and responsive variants, you would have to use melid widgets (Box) from that.
from melid.tailwind import Tailwind
print(
Tailwind().tw(
"Button",
"bg-blue-300 text-black hover:bg-blue-500 rounded-md hover:p-sm ml-sm",
)
)
State Management
Melid provided a way to make data reactive to widgets, with the help of PyQt5 signals and slots.
from PyQt5 import QtWidgets
from PyQt5.QtCore import Qt
from melid.layout import Box
from melid.store import State
from melid.tailwind import Tailwind
from melid.widgets import Button, Input, InputType
username = State("")
password = State("")
show_password = State(False)
update_title = lambda: ["%s / %s" % (username.get(), password.get())]
tw = Tailwind().tw
Box(
[
Input(
placeholder="Password",
on_change=lambda val: password.set(val),
input_type=InputType.PASSWORD,
style=tw(
"Input",
"p-2 rounded-none bg-gray-900 w-full h-full",
),
)
.state(password, lambda: password.get() == "pass", "deleteLater")
.state(
show_password,
lambda: show_password.get() == True,
"setEchoMode",
[QtWidgets.QLineEdit.Normal],
)
.state(
show_password,
lambda: show_password.get() == False,
"setEchoMode",
[QtWidgets.QLineEdit.Password],
),
Button(
"show",
style=tw(
"Button",
"p-2 rounded-none bg-gray-900 h-full",
),
on_click=lambda: show_password.set(not show_password.get()),
)
.state(
show_password,
lambda: show_password.get() == True,
"setText",
["hide"],
)
.state(
show_password,
lambda: show_password.get() == False,
"setText",
["show"],
),
],
alignment=Qt.AlignmentFlag.AlignVCenter,
style=tw("Box", "max-h-10"),
)
Metadata
Release files for melid 1.0.17
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 |
|---|---|---|---|---|
| melid-1.0.17.tar.gz | 18.6 kB | Without provenance | Details for melid-1.0.17.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| melid-1.0.17-py3-none-any.whl | Python 3 | none | any | Details for melid-1.0.17-py3-none-any.whl |
Total release size: 39.2 kB
Release files / melid-1.0.17.tar.gz
| Download URL | melid-1.0.17.tar.gz |
|---|---|
| Size | 18.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
abbcfd56c0a0938ba2f5372d321f9f74e5189272804fcc53a00bf5e90c6ced2b
|
|
BLAKE2b-256 checksum How to use checksums |
7cbaf28c8f0b7f2f2cfea49dcaaf9cd924b04c17bb7112d1a5f430078e1cd9e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.4.22
|
Release files / melid-1.0.17-py3-none-any.whl
| Download URL | melid-1.0.17-py3-none-any.whl |
|---|---|
| Size | 20.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a0c99aa65107d69f53a8a8e248242fa715b846e9b616fbeece406ba0478436bc
|
|
BLAKE2b-256 checksum How to use checksums |
0881a9d95f09162236df602185503dc7d6fe83973ff7a785404a453bc9d63c6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.4.22
|
Security for melid 1.0.17
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.