# CvaniaK's Widgets for Textual TUI (`ck_widgets`)
This is list of Widgets for [Textual](https://github.com/Textualize/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:
```bash
pip3 install ck-widgets
# or
python3 -m pip install ck-widgets
```
# ValueBar

<details>
<summary>Examples</summary>
The simples example:
```python
# 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:

```python
# 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:
```bash
python3 -m ck_widgets.examples.value_bar
```
</details>
<details>
<summary>Known Limitations</summary>
* You need to force size of layout to be not smaller than maximum size of of ValueBar (otherwise it will behave badly)
* ...
</details>
<details>
<summary>TODO</summary>
* 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
* ...
</details>
# ListViewUo

While waiting for [ticket](https://github.com/Textualize/textual/projects/1#card-66941810) (also mentioned [here](https://github.com/Textualize/textual/discussions/196)) and official `ListView`, you can use this dirty version that allows you to scroll thrue list of widgets.
<details>
<summary>Examples</summary>
You can use it this way:
```python
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):
```python
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()
```
</details>
# Change Log
## [0.2.0] - 2022-04-11
### Added
* ListViewUo from previous [repo](https://github.com/Cvaniak/TextualListViewUnofficial)
## [0.1.0] - 2022-02-26
### Added
* ValueBar
* Test version of DebugWidget
Raw data
{
"_id": null,
"home_page": "http://github.com/Cvaniak/CvaniaksTextualWidgets",
"name": "ck-widgets",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Cvaniak",
"author_email": "igna.cwaniak@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/d7/d3/b84e67762db42dc800b29b24b5c0324fb3ad62a63e9b256c4bb6ea372333/ck-widgets-0.2.0.tar.gz",
"platform": null,
"description": "# CvaniaK's Widgets for Textual TUI (`ck_widgets`)\n\nThis is list of Widgets for [Textual](https://github.com/Textualize/textual) framework, created from my personal need.\n\n> \u26a0 **NOTE:** This project widgets names, arguments, etc. can vary along diffrent versions.\n\n# Install\nThis is pip package so you can install it using command below:\n```bash\npip3 install ck-widgets\n# or \npython3 -m pip install ck-widgets\n```\n\n# ValueBar\n \n<details>\n<summary>Examples</summary>\n\nThe simples example:\n\n```python\n# Simples value bar\nfrom ck_widgets.widgets import ValueBarH, ValueBarV\nvbar_horizontal = ValueBarH(max_value=50)\n# or \nvbar_vertical = ValueBarV(max_value=50)\n``` \n\nAnd here is example with almost all arguments:\n\n\n\n```python\n# Example with almost all arguments\nfrom ck_widgets.widgets import ValueBarH, CColor, CustomColor\nfrom rich import box\n\nbackground_color: List[CColor] = [\"rgb(0,0,0)\", \"rgb(0,0,0)\", \"yellow\"]\nValueBarH(\n name=\"name_to_catch_in_event\",\n label=\"Almost all arguments\",\n label_align=\"left\",\n label_position=\"bottom\",\n start_value=25,\n max_value=50,\n height=6,\n instant=True,\n reversed=True,\n color=CustomColor.gradient(\"green\", \"rgb(0, 100, 250)\"),\n bg_color=background_color,\n border_style=\"yellow\",\n padding=(1,1),\n box=box.DOUBLE_EDGE,\n)\n``` \n\nAnd this example: \n\n\nyou can check code in this file `ck_widgets/exmples/value_bar.py` or test it by using command below: \n\n```bash\npython3 -m ck_widgets.examples.value_bar\n```\n\n</details>\n\n<details>\n<summary>Known Limitations</summary>\n\n* You need to force size of layout to be not smaller than maximum size of of ValueBar (otherwise it will behave badly)\n* ...\n\n</details>\n\n<details>\n<summary>TODO</summary>\n\n* Reactive version (so it gives values from 0 to 1 and can be resized/'squashed') \n* Be sure that provide all arguments \n* Test edge cases \n* Clean up how to provide color \n* Label on left or right site \n* ...\n\n</details>\n\n\n# ListViewUo\n \nWhile waiting for [ticket](https://github.com/Textualize/textual/projects/1#card-66941810) (also mentioned [here](https://github.com/Textualize/textual/discussions/196)) and official `ListView`, you can use this dirty version that allows you to scroll thrue list of widgets. \n\n<details>\n<summary>Examples</summary>\nYou can use it this way:\n\n```python\nfrom ck_widgets_lv import ListViewUo\n\nclass TestListView(App):\n async def on_mount(self, event: events.Mount) -> None:\n await self.view.dock(ListViewUo([Placeholder(height=10) for _ in range(20)]))\n\nif __name__ == \"__main__\":\n TestListView.run()\n```\n\nor more complex example (from gif demo above):\n```python\nfrom textual.widgets import Placeholder\nfrom textual.widget import Widget\nfrom textual.events import Message\nfrom textual.app import App\nfrom textual import events\n\nfrom ck_widgets.widgets import ListViewUo\n\nif __name__ == \"__main__\":\n from textual.widgets import Footer\n\n class DeleteStatus(Message):\n def __init__(self, sender: Widget):\n super().__init__(sender)\n self.to_delete = sender\n\n class DeletablePlaceholder(Placeholder):\n async def on_click(self, event: events.Click) -> None:\n await self.emit(DeleteStatus(self))\n\n class TestListView(App):\n async def action_add(self) -> None:\n await self.list_view.add_widget(DeletablePlaceholder(height=10))\n self.refresh()\n\n async def action_add_index_2(self) -> None:\n await self.list_view.add_widget(DeletablePlaceholder(height=10), index=2)\n self.refresh()\n\n async def action_remove(self) -> None:\n await self.list_view.remove_widget_by_index()\n self.refresh()\n\n async def action_remove_index_2(self) -> None:\n await self.list_view.remove_widget_by_index(index=2)\n self.refresh()\n\n async def on_load(self, _: events.Load) -> None:\n await self.bind(\"a\", \"add()\", \"Add Widget\")\n await self.bind(\"s\", \"add_index_2()\", \"Add Widget in index 2\")\n await self.bind(\"r\", \"remove()\", \"Remove Widget\")\n await self.bind(\"e\", \"remove_index_2()\", \"Remove Widget in index 2\")\n await self.bind(\"Click Widget\", \"_()\", \"To delete it\")\n\n async def on_mount(self, event: events.Mount) -> None:\n self.list_view = ListViewUo(\n [DeletablePlaceholder(height=10) for _ in range(7)]\n )\n\n await self.view.dock(Footer(), edge=\"bottom\")\n await self.view.dock(self.list_view)\n\n async def handle_delete_status(self, message: DeleteStatus):\n await self.list_view.remove_widget(message.to_delete)\n\n TestListView.run()\n```\n\n</details>\n\n# Change Log\n\n## [0.2.0] - 2022-04-11\n\n### Added\n* ListViewUo from previous [repo](https://github.com/Cvaniak/TextualListViewUnofficial)\n\n## [0.1.0] - 2022-02-26\n\n### Added\n* ValueBar\n* Test version of DebugWidget\n\n\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Package with widgets and components for Textual TUI Framework.",
"version": "0.2.0",
"project_urls": {
"Homepage": "http://github.com/Cvaniak/CvaniaksTextualWidgets"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "60c58203e06bf25bf9f3f0dc84f0f737a5a7006a733b1f401616c8d7c2efbada",
"md5": "77c395a38a711f6fa50cff4725622b48",
"sha256": "5eeeef10ac4ac8756b0deb7bd7eca295ed07c3a64290372bf280f9f5397e645e"
},
"downloads": -1,
"filename": "ck_widgets-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "77c395a38a711f6fa50cff4725622b48",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 12527,
"upload_time": "2022-04-11T21:39:30",
"upload_time_iso_8601": "2022-04-11T21:39:30.625610Z",
"url": "https://files.pythonhosted.org/packages/60/c5/8203e06bf25bf9f3f0dc84f0f737a5a7006a733b1f401616c8d7c2efbada/ck_widgets-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d7d3b84e67762db42dc800b29b24b5c0324fb3ad62a63e9b256c4bb6ea372333",
"md5": "0843c02b8e181404bee3be18e9a6f40c",
"sha256": "ab49b8e2b72b6b8621c99d8eab9f815faaeca7124da9ed4c68055f692f7ad4ed"
},
"downloads": -1,
"filename": "ck-widgets-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "0843c02b8e181404bee3be18e9a6f40c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 11238,
"upload_time": "2022-04-11T21:39:32",
"upload_time_iso_8601": "2022-04-11T21:39:32.859587Z",
"url": "https://files.pythonhosted.org/packages/d7/d3/b84e67762db42dc800b29b24b5c0324fb3ad62a63e9b256c4bb6ea372333/ck-widgets-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-04-11 21:39:32",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Cvaniak",
"github_project": "CvaniaksTextualWidgets",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "ck-widgets"
}