flet-timer


Nameflet-timer JSON
Version 0.0.13 PyPI version JSON
download
home_pagehttps://github.com/panos-stavrianos/flet_timer
SummaryA simple component to add a timer to your flet app!
upload_time2023-07-07 11:07:52
maintainer
docs_urlNone
authorPanos Stavrianos
requires_python>=3.6
licenseMIT license
keywords flet flet_timer timer flet app flet components python gui ui
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Flet Timer
 
[![PyPI Version](https://img.shields.io/pypi/v/flet-timer.svg)](https://pypi.org/project/flet-timer/)
[![License](https://img.shields.io/github/license/panos-stavrianos/flet_timer.svg)](https://opensource.org/licenses/MIT)

The Flet Timer is a timer component for the Flet framework that is based
on the last example from the [Flet User Controls guide](https://flet.dev/docs/guides/python/user-controls/).
It demonstrates how to create a countdown timer using threading for real-time display updates.

## Installation

To use the Flet Timer, you can install it using pip:

```
pip install flet-timer
```

## Usage

Here's an example that demonstrates how to use the Flet Timer.

First, let's define a callback function that will execute at a specified interval:

```python
def refresh():
    txt_time.value = datetime.now().strftime("%H:%M:%S")
    page.update()
```

Next, create the Timer object with the desired interval in seconds, a name, and the callback:

```python
timer = Timer(name="timer", interval_s=1, callback=refresh)
```

Finally, add the Timer component to the page:

```python
page.add(timer)
```

The complete example code would look like this:

```python
from datetime import datetime
import flet as ft
from flet_timer.flet_timer import Timer


def main(page: ft.Page):
    page.title = "Flet Timer example"
    page.vertical_alignment = ft.MainAxisAlignment.CENTER
    page.horizontal_alignment = ft.CrossAxisAlignment.CENTER

    txt_time = ft.Text(value="None")

    def refresh():
        txt_time.value = datetime.now().strftime("%H:%M:%S")
        page.update()

    timer = Timer(name="timer", interval_s=1, callback=refresh)

    page.add(
        timer,
        txt_time
    )


ft.app(main)
```

In this example, we create a Flet application that displays the current time using the `Text` component. We define
a `refresh()` function that updates the `txt_time` value with the current time and triggers a page update. We
instantiate a `Timer` with a 1-second interval and the `refresh()` function as the callback. The timer continuously
calls the callback, updating the UI with the current time.

Certainly! Here's the disclaimer in markdown format:

## Disclaimer

Please note that this package is provided as-is and has not been extensively tested.
While the provided functionality should work in most situations,
there is a possibility of unforeseen issues or compatibility conflicts.

It is recommended to thoroughly test the package and adapt it to your specific use case before deploying it in a
production environment.

## Contributing

Contributions to the Flet Timer project are welcome! If you find any issues or have suggestions for improvements, please
open an issue or submit a pull request on the [GitHub repository](https://github.com/panos-stavrianos/flet_timer).

## License

The Flet Timer is open-source software released under the [MIT License](https://opensource.org/licenses/MIT). See
the [LICENSE](https://github.com/example/flet-timer/blob/main/LICENSE) file for more information.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/panos-stavrianos/flet_timer",
    "name": "flet-timer",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "flet,flet_timer,timer,flet app,flet components,python,gui,ui",
    "author": "Panos Stavrianos",
    "author_email": "panos@orbitsystems.gr",
    "download_url": "https://files.pythonhosted.org/packages/a8/af/fd8454dcf2a7c13dfd3a98b7cff8b16c385d3007212e567c4548f6054eff/flet_timer-0.0.13.tar.gz",
    "platform": null,
    "description": "# Flet Timer\n \n[![PyPI Version](https://img.shields.io/pypi/v/flet-timer.svg)](https://pypi.org/project/flet-timer/)\n[![License](https://img.shields.io/github/license/panos-stavrianos/flet_timer.svg)](https://opensource.org/licenses/MIT)\n\nThe Flet Timer is a timer component for the Flet framework that is based\non the last example from the [Flet User Controls guide](https://flet.dev/docs/guides/python/user-controls/).\nIt demonstrates how to create a countdown timer using threading for real-time display updates.\n\n## Installation\n\nTo use the Flet Timer, you can install it using pip:\n\n```\npip install flet-timer\n```\n\n## Usage\n\nHere's an example that demonstrates how to use the Flet Timer.\n\nFirst, let's define a callback function that will execute at a specified interval:\n\n```python\ndef refresh():\n    txt_time.value = datetime.now().strftime(\"%H:%M:%S\")\n    page.update()\n```\n\nNext, create the Timer object with the desired interval in seconds, a name, and the callback:\n\n```python\ntimer = Timer(name=\"timer\", interval_s=1, callback=refresh)\n```\n\nFinally, add the Timer component to the page:\n\n```python\npage.add(timer)\n```\n\nThe complete example code would look like this:\n\n```python\nfrom datetime import datetime\nimport flet as ft\nfrom flet_timer.flet_timer import Timer\n\n\ndef main(page: ft.Page):\n    page.title = \"Flet Timer example\"\n    page.vertical_alignment = ft.MainAxisAlignment.CENTER\n    page.horizontal_alignment = ft.CrossAxisAlignment.CENTER\n\n    txt_time = ft.Text(value=\"None\")\n\n    def refresh():\n        txt_time.value = datetime.now().strftime(\"%H:%M:%S\")\n        page.update()\n\n    timer = Timer(name=\"timer\", interval_s=1, callback=refresh)\n\n    page.add(\n        timer,\n        txt_time\n    )\n\n\nft.app(main)\n```\n\nIn this example, we create a Flet application that displays the current time using the `Text` component. We define\na `refresh()` function that updates the `txt_time` value with the current time and triggers a page update. We\ninstantiate a `Timer` with a 1-second interval and the `refresh()` function as the callback. The timer continuously\ncalls the callback, updating the UI with the current time.\n\nCertainly! Here's the disclaimer in markdown format:\n\n## Disclaimer\n\nPlease note that this package is provided as-is and has not been extensively tested.\nWhile the provided functionality should work in most situations,\nthere is a possibility of unforeseen issues or compatibility conflicts.\n\nIt is recommended to thoroughly test the package and adapt it to your specific use case before deploying it in a\nproduction environment.\n\n## Contributing\n\nContributions to the Flet Timer project are welcome! If you find any issues or have suggestions for improvements, please\nopen an issue or submit a pull request on the [GitHub repository](https://github.com/panos-stavrianos/flet_timer).\n\n## License\n\nThe Flet Timer is open-source software released under the [MIT License](https://opensource.org/licenses/MIT). See\nthe [LICENSE](https://github.com/example/flet-timer/blob/main/LICENSE) file for more information.\n",
    "bugtrack_url": null,
    "license": "MIT license",
    "summary": "A simple component to add a timer to your flet app!",
    "version": "0.0.13",
    "project_urls": {
        "Homepage": "https://github.com/panos-stavrianos/flet_timer"
    },
    "split_keywords": [
        "flet",
        "flet_timer",
        "timer",
        "flet app",
        "flet components",
        "python",
        "gui",
        "ui"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "537ab39f2dec4d985349ddfa9d619fd5c1288bb4fa95517d6ad2e91e3a9745fb",
                "md5": "6cd68fdb409172c90410ac34e836eba0",
                "sha256": "85e2f967efd255787c7fbc301df831392c7ffbbc82672751386e2d9090ecf57d"
            },
            "downloads": -1,
            "filename": "flet_timer-0.0.13-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6cd68fdb409172c90410ac34e836eba0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 4108,
            "upload_time": "2023-07-07T11:07:51",
            "upload_time_iso_8601": "2023-07-07T11:07:51.578969Z",
            "url": "https://files.pythonhosted.org/packages/53/7a/b39f2dec4d985349ddfa9d619fd5c1288bb4fa95517d6ad2e91e3a9745fb/flet_timer-0.0.13-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a8affd8454dcf2a7c13dfd3a98b7cff8b16c385d3007212e567c4548f6054eff",
                "md5": "6435373e21a8fbb865a79d4740e4a31b",
                "sha256": "c55fec469f42ca897ff7603dc2db219530369931aa7b5fc6449ac8ea3a37aee6"
            },
            "downloads": -1,
            "filename": "flet_timer-0.0.13.tar.gz",
            "has_sig": false,
            "md5_digest": "6435373e21a8fbb865a79d4740e4a31b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 3874,
            "upload_time": "2023-07-07T11:07:52",
            "upload_time_iso_8601": "2023-07-07T11:07:52.890371Z",
            "url": "https://files.pythonhosted.org/packages/a8/af/fd8454dcf2a7c13dfd3a98b7cff8b16c385d3007212e567c4548f6054eff/flet_timer-0.0.13.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-07 11:07:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "panos-stavrianos",
    "github_project": "flet_timer",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "flet-timer"
}
        
Elapsed time: 0.13154s