https://github.com/omamkaz/flet-timer
It demonstrates how to create a countdown timer using threading for real-time display updates.
https://github.com/omamkaz/flet-timer
Last synced: 8 months ago
JSON representation
It demonstrates how to create a countdown timer using threading for real-time display updates.
- Host: GitHub
- URL: https://github.com/omamkaz/flet-timer
- Owner: omamkaz
- License: mit
- Created: 2024-12-06T18:15:35.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-24T23:15:17.000Z (11 months ago)
- Last Synced: 2025-02-09T00:14:35.379Z (10 months ago)
- Language: Python
- Size: 31.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-flet - FletTimer - It demonstrates how to create a countdown timer using threading for real-time display updates. (Uncategorized / Uncategorized)
README
# Flet Timer v1.0.2
The `Timer` is a timer class
It demonstrates how to create a countdown timer using threading for real-time display updates.
## Features
- Countdown Timer: Implements a dynamic countdown.
- Real-Time Updates: Displays updates in real time.
- Threading: Uses threading for non-blocking execution.
## Installation
You can install Flet Timer using pip:
```bash
pip install git+https://github.com/omamkaz/flet-timer.git
```
## Usage
Here's an example that demonstrates how to use the `Timer` and `debounce`.
### debounce
```python
from flet_timer import debounce
@debounce(0.3)
def func(*args, **kwargs) -> None:
print("Hi...")
```
### Timer
```python
import flet as ft
from flet_timer import Timer
from datetime import datetime
def main(page: ft.Page):
page.title = "Timer Example 1"
page.vertical_alignment = ft.MainAxisAlignment.CENTER
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
page.window.width = 360
page.window.height = 600
def update_time():
timer_txt.value = datetime.now().strftime("%H:%M:%S")
page.update()
timer = Timer(callback=update_time)
timer_txt = ft.Text(
value=datetime.now().strftime("%H:%M:%S"),
text_align="center",
size=24
)
page.add(
timer_txt,
ft.Button(
text = "Start",
on_click=lambda e: timer.start()
),
ft.Button(
text = "Stop",
on_click=lambda e: timer.stop()
),
ft.Button(
text = "Pause",
on_click=lambda e: timer.pause()
),
ft.Button(
text = "Resume",
on_click=lambda e: timer.resume()
)
)
ft.app(target=main)
```
## Output of above code
