CvaniaK's Widgets for Textual TUI (ck_widgets)
This is list of Widgets for Textual framework, created from my personal need.
⚠ NOTE: This project widgets names, arguments, etc. can vary along diffrent versions.
Install
This is pip package so you can install it using command below:
pip3 install ck-widgets
# or
python3 -m pip install ck-widgets
ValueBar
Examples
The simples example:
# Simples value bar
from ck_widgets.widgets import ValueBarH, ValueBarV
vbar_horizontal = ValueBarH(max_value=50)
# or
vbar_vertical = ValueBarV(max_value=50)
And here is example with almost all arguments:
# Example with almost all arguments
from ck_widgets.widgets import ValueBarH, CColor, CustomColor
from rich import box
background_color: List[CColor] = ["rgb(0,0,0)", "rgb(0,0,0)", "yellow"]
ValueBarH(
name="name_to_catch_in_event",
label="Almost all arguments",
label_align="left",
label_position="bottom",
start_value=25,
max_value=50,
height=6,
instant=True,
reversed=True,
color=CustomColor.gradient("green", "rgb(0, 100, 250)"),
bg_color=background_color,
border_style="yellow",
padding=(1,1),
box=box.DOUBLE_EDGE,
)
And this example:
you can check code in this file ck_widgets/exmples/value_bar.py or test it by using command below:
python3 -m ck_widgets.examples.value_bar
Known Limitations
- You need to force size of layout to be not smaller than maximum size of of ValueBar (otherwise it will behave badly)
- ...
TODO
- Reactive version (so it gives values from 0 to 1 and can be resized/'squashed')
- Be sure that provide all arguments
- Test edge cases
- Clean up how to provide color
- Label on left or right site
- ...
ListViewUo
While waiting for ticket (also mentioned here) and official ListView, you can use this dirty version that allows you to scroll thrue list of widgets.
Examples
You can use it this way:from ck_widgets_lv import ListViewUo
class TestListView(App):
async def on_mount(self, event: events.Mount) -> None:
await self.view.dock(ListViewUo([Placeholder(height=10) for _ in range(20)]))
if __name__ == "__main__":
TestListView.run()
or more complex example (from gif demo above):
from textual.widgets import Placeholder
from textual.widget import Widget
from textual.events import Message
from textual.app import App
from textual import events
from ck_widgets.widgets import ListViewUo
if __name__ == "__main__":
from textual.widgets import Footer
class DeleteStatus(Message):
def __init__(self, sender: Widget):
super().__init__(sender)
self.to_delete = sender
class DeletablePlaceholder(Placeholder):
async def on_click(self, event: events.Click) -> None:
await self.emit(DeleteStatus(self))
class TestListView(App):
async def action_add(self) -> None:
await self.list_view.add_widget(DeletablePlaceholder(height=10))
self.refresh()
async def action_add_index_2(self) -> None:
await self.list_view.add_widget(DeletablePlaceholder(height=10), index=2)
self.refresh()
async def action_remove(self) -> None:
await self.list_view.remove_widget_by_index()
self.refresh()
async def action_remove_index_2(self) -> None:
await self.list_view.remove_widget_by_index(index=2)
self.refresh()
async def on_load(self, _: events.Load) -> None:
await self.bind("a", "add()", "Add Widget")
await self.bind("s", "add_index_2()", "Add Widget in index 2")
await self.bind("r", "remove()", "Remove Widget")
await self.bind("e", "remove_index_2()", "Remove Widget in index 2")
await self.bind("Click Widget", "_()", "To delete it")
async def on_mount(self, event: events.Mount) -> None:
self.list_view = ListViewUo(
[DeletablePlaceholder(height=10) for _ in range(7)]
)
await self.view.dock(Footer(), edge="bottom")
await self.view.dock(self.list_view)
async def handle_delete_status(self, message: DeleteStatus):
await self.list_view.remove_widget(message.to_delete)
TestListView.run()
Change Log
[0.2.0] - 2022-04-11
Added
- ListViewUo from previous repo
[0.1.0] - 2022-02-26
Added
- ValueBar
- Test version of DebugWidget
Metadata
Release files for ck-widgets 0.2.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 | Actions |
|---|---|---|---|---|
| ck-widgets-0.2.0.tar.gz | 11.2 kB | Without provenance | Details for ck-widgets-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ck_widgets-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for ck_widgets-0.2.0-py3-none-any.whl |
Total release size: 23.8 kB
Release files / ck-widgets-0.2.0.tar.gz
| Download URL | ck-widgets-0.2.0.tar.gz |
|---|---|
| Size | 11.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ab49b8e2b72b6b8621c99d8eab9f815faaeca7124da9ed4c68055f692f7ad4ed
|
|
BLAKE2b-256 checksum How to use checksums |
d7d3b84e67762db42dc800b29b24b5c0324fb3ad62a63e9b256c4bb6ea372333
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.10.2
|
Release files / ck_widgets-0.2.0-py3-none-any.whl
| Download URL | ck_widgets-0.2.0-py3-none-any.whl |
|---|---|
| Size | 12.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5eeeef10ac4ac8756b0deb7bd7eca295ed07c3a64290372bf280f9f5397e645e
|
|
BLAKE2b-256 checksum How to use checksums |
60c58203e06bf25bf9f3f0dc84f0f737a5a7006a733b1f401616c8d7c2efbada
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.10.2
|
Security for ck-widgets 0.2.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.