Brython-components
Brython-components is an easy implementation of brython's webcomonent.
Installation
Use the package manager pip to install.
pip install brip
brip install brython-components
Usage
file.html
<popup-info>
<span slot="data-text">Popup info data</span>
</popup-info>
file.py
from browser import html
from brython_components import bind, customElement, defineElement, react
html.maketag("SLOT")
@defineElement("popup-info")
class PopupInfo(customElement):
def __init__(self):
super().__init__()
self.render_root <= html.STYLE('''
.wrapper {
position: relative;
}
.info {
font-size: 0.8rem;
width: 200px;
display: inline-block;
border: 1px solid black;
padding: 10px;
background: white;
border-radius: 10px;
opacity: 0;
transition: 0.6s all;
position: absolute;
top: 20px;
left: 10px;
z-index: 3;
}
.icon:hover + .info, .icon:focus + .info {
opacity: 1;
}
''')
wrapper = html.SPAN(Class="wrapper")
icon = html.SPAN(Class="icon", tabindex="0")
wrapper <= icon
info = html.SPAN(Class="info")
info <= html.SLOT(name="data-text")
wrapper <= info
self.render_root <= wrapper
@bind(".icon", "click")
def deactivate(self, event):
info = self.render_root.select_one(".info")
icon = event.target
if not info.style.opacity:
info.style["opacity"] = 1
icon.style["text-decoration"] = "line-through"
else:
info.style["opacity"] = ""
icon.style["text-decoration"] = ""
@react(".icon")
def completed(self, targets):
targets[0].text = ":) hover me"
License
Metadata
Release files for brython-components 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| brython_components-0.3.1.tar.gz | 3.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| brython_components-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.5 kB
Release files / brython_components-0.3.1.tar.gz
| Download URL | brython_components-0.3.1.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c739a3d38d95ad47039536b9769fbc4a4659f103e0a987186749f6886b4b3712
|
|
BLAKE2b-256 checksum How to use checksums |
cca8ab1ce602c18d326980e89953799e64653b6c246bb30d831518cb27ccbf06
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.10.9 Windows/10
|
Release files / brython_components-0.3.1-py3-none-any.whl
| Download URL | brython_components-0.3.1-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
76b339b84275abbb30ca755cc6ba6e2cc17d8f19ac8b1b358e43b0f676ae3b1b
|
|
BLAKE2b-256 checksum How to use checksums |
22f6c8f6f9b422b450aac319753ae5dead79554f77831271e263e289beee2c95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.10.9 Windows/10
|