# textual-qrcode
## Introduction
While, I admit, likely of little utility really, this library aims to show
one possible way of writing and "shipping" a custom widget for
[Textual](https://textual.textualize.io/). Key here is that the library
contains and provides a custom widget which can be imported and used in an
application; but it also provides a simple application that can be run to
see the widget in action.
## Please note!
This library is just a thin wrapper around <https://qrenco.de/>. Each time
you create a QR code the content you encode is sent to that website. It also
means, of course, that this is only usable with a working net connection.
Please keep these things in mind if you do decide to actually use this for
something.
## Installing
The library itself can be installed with `pip`:
```sh
$ pip install textual-qrcode
```
or with your Python environment manager of choice.
## Running the test application
The demo/test application can be run like this:
```sh
$ python -m textual_qrcode
```
When you've finished testing, press <kbd>Ctrl</kbd>+<kbd>C</kbd> to quit.
## Using the widget
To make use of the `QRCode` widget, import it into your code:
```python
from textual_qrcode import QRCode
```
The widget itself takes all of the arguments that a normal Textual `Widget`
takes, but has the addition of an initial positional argument which is some
text to encode. An example use of it could look like:
```python
def compose( self ) -> ComposeResult:
yield Header()
yield QRCode( "https://textual.textualize.io/" )
yield Footer()
```
The widget also has a `encode` method, that lets you update the QR code to
display something else. For example:
```python
self.query_one( QRCode ).encode( "Now I've changed it to this" )
```
The widget will send out one of two messages when an attempt is made to
encode some content. If the content was encoded fine a `QRCode.Encoded`
message is sent out, which can be caught like this:
```python
def on_qrcode_encoded( self, event: QRCode.Encoded ) -> None:
# Do something now that the QR code was updated fine.
```
If there is an error encoding the content `QRCode.Error` will be sent out.
this can be used like this:
```python
def on_qrcode_error( self, event: QRCode.Error ) -> None:
# Do something about the error.
```
In both cases the event sent out has a `qr_code` property which is the
`QRCode` widget involved.
[//]: # (README.md ends here)
Raw data
{
"_id": null,
"home_page": "https://github.com/davep/textual-qrcode",
"name": "textual-qrcode",
"maintainer": "Dave Pearson",
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "davep@davep.org",
"keywords": "library widget textual qrcode",
"author": "Dave Pearson",
"author_email": "davep@davep.org",
"download_url": "",
"platform": null,
"description": "# textual-qrcode\n\n## Introduction\n\nWhile, I admit, likely of little utility really, this library aims to show\none possible way of writing and \"shipping\" a custom widget for\n[Textual](https://textual.textualize.io/). Key here is that the library\ncontains and provides a custom widget which can be imported and used in an\napplication; but it also provides a simple application that can be run to\nsee the widget in action.\n\n## Please note!\n\nThis library is just a thin wrapper around <https://qrenco.de/>. Each time\nyou create a QR code the content you encode is sent to that website. It also\nmeans, of course, that this is only usable with a working net connection.\nPlease keep these things in mind if you do decide to actually use this for\nsomething.\n\n## Installing\n\nThe library itself can be installed with `pip`:\n\n```sh\n$ pip install textual-qrcode\n```\n\nor with your Python environment manager of choice.\n\n## Running the test application\n\nThe demo/test application can be run like this:\n\n```sh\n$ python -m textual_qrcode\n```\n\nWhen you've finished testing, press <kbd>Ctrl</kbd>+<kbd>C</kbd> to quit.\n\n## Using the widget\n\nTo make use of the `QRCode` widget, import it into your code:\n\n```python\nfrom textual_qrcode import QRCode\n```\n\nThe widget itself takes all of the arguments that a normal Textual `Widget`\ntakes, but has the addition of an initial positional argument which is some\ntext to encode. An example use of it could look like:\n\n```python\n def compose( self ) -> ComposeResult:\n yield Header()\n yield QRCode( \"https://textual.textualize.io/\" )\n yield Footer()\n```\n\nThe widget also has a `encode` method, that lets you update the QR code to\ndisplay something else. For example:\n\n```python\nself.query_one( QRCode ).encode( \"Now I've changed it to this\" )\n```\n\nThe widget will send out one of two messages when an attempt is made to\nencode some content. If the content was encoded fine a `QRCode.Encoded`\nmessage is sent out, which can be caught like this:\n\n```python\ndef on_qrcode_encoded( self, event: QRCode.Encoded ) -> None:\n # Do something now that the QR code was updated fine.\n```\n\nIf there is an error encoding the content `QRCode.Error` will be sent out.\nthis can be used like this:\n\n```python\ndef on_qrcode_error( self, event: QRCode.Error ) -> None:\n # Do something about the error.\n```\n\nIn both cases the event sent out has a `qr_code` property which is the\n`QRCode` widget involved.\n\n[//]: # (README.md ends here)\n",
"bugtrack_url": null,
"license": "License :: OSI Approved :: MIT License",
"summary": "A library and terminal wrapper around qrenco.de.",
"version": "0.2.0",
"split_keywords": [
"library",
"widget",
"textual",
"qrcode"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "08585a1b4c4ce3b039dee290f61cb8fb6c463c6ca77db8a714488d736ee808b9",
"md5": "94df6a0c6872e9df6acfcd4b0e3119a0",
"sha256": "b1705547af5a7b76b25ca95ed62f6166f867147ccc9e1414c2eb377a078251a1"
},
"downloads": -1,
"filename": "textual_qrcode-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "94df6a0c6872e9df6acfcd4b0e3119a0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 6210,
"upload_time": "2023-01-21T19:16:59",
"upload_time_iso_8601": "2023-01-21T19:16:59.184497Z",
"url": "https://files.pythonhosted.org/packages/08/58/5a1b4c4ce3b039dee290f61cb8fb6c463c6ca77db8a714488d736ee808b9/textual_qrcode-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-21 19:16:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "davep",
"github_project": "textual-qrcode",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "textual-qrcode"
}