Skip to main content

Flet Timer

PyPI Version License

The Flet Timer is a timer component for the Flet framework that is based on the last example from the Flet User Controls guide. 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:

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:

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

Finally, add the Timer component to the page:

page.add(timer)

The complete example code would look like this:

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.

License

The Flet Timer is open-source software released under the MIT License. See the LICENSE file for more information.

Metadata

Release files for flet-timer 0.0.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flet-timer 0.0.13
File Size Uploaded
flet_timer-0.0.13.tar.gz 3.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flet-timer 0.0.13
File Interpreter ABI Platform
flet_timer-0.0.13-py3-none-any.whl Python 3 none any Details

Total release size: 8.0 kB

Release files / flet_timer-0.0.13.tar.gz

Download URL flet_timer-0.0.13.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c55fec469f42ca897ff7603dc2db219530369931aa7b5fc6449ac8ea3a37aee6
BLAKE2b-256 checksum
How to use checksums
a8affd8454dcf2a7c13dfd3a98b7cff8b16c385d3007212e567c4548f6054eff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.17

Release files / flet_timer-0.0.13-py3-none-any.whl

Download URL flet_timer-0.0.13-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
85e2f967efd255787c7fbc301df831392c7ffbbc82672751386e2d9090ecf57d
BLAKE2b-256 checksum
How to use checksums
537ab39f2dec4d985349ddfa9d619fd5c1288bb4fa95517d6ad2e91e3a9745fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.17

Release history Release notifications | RSS feed

This release

0.0.13 This release

2 release files

0.0.8

2 release files

0.0.6

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page