Skip to main content

The Progress Panel is a custom tkinter widget that displays a progress bar and buttons (Start/Resume, Pause, Terminate) to control a user-defined task that runs in a separate thread.

Project description

Progresspanel

The Progresspanel is a custom tkinter widget that displays a progress bar and buttons (Start/Resume, Pause, Terminate) to control a user-defined task that runs in a separate thread. The widget is implemented in progresspanel.py.

Installation

You can install Progresspanel using pip for the Python environment:

pip install progresspanel

Usage

To use the Progress Panel, you need to create an instance of the Progresspanel class and pass it a parent widget, a total number of iterations, and a task function to be run in a loop.

Here below is an example code that creates a window with a progress bar and buttons to control the task as shown in the GIF:

progress_demo

import tkinter as tk
from progresspanel import Progresspanel
from time import sleep

root = tk.Tk()
panel = Progresspanel(root, title="Sample Task")
panel.pack()

def sample_task():
    total = 5
    panel.set_total(total)
    for i in range(total):
        panel.update(i)
        print("Running iteration: {}".format(i))
        sleep(1)

panel.set_task(sample_task)
root.mainloop()

The task function simply sleeps for one second five times and updates the progress bar each time.

You can customize the task function to do whatever you want. You can also customize the title of the progress panel and enable/disable verbose mode to print status updates to the console. There're also advanced features that let you pause execution in between time-consuming methods in your own task, and features that let you repeat the last iteration right after resuming from a pausing. Check below APIs for more details.

API

Progresspanel(parent, total=1, task=None, title=None, verbose=True)

Create a new Progresspanel widget.

  • parent: the parent widget.
  • total: the total number of iterations for the task.
  • task: the task function to be run in a loop.
  • title: the title of the progress panel.
  • display_time_left: a bool to determine whether to display the remaining time in the status label, default to True.
  • verbose: whether to print status updates to the console.

set_total(total)

Set the total number of iterations for the task.

set_task(task)

Set the task function.

update(i)

Update the progress bar with the current iteration number.

set_verbose(verbose)

Enable/disable verbose mode to print status updates to the console.

is_pausing_or_terminating()

Check if the task is in a pausing or terminating state. This is useful for user to stop promptly before running other time-consuming operations in user-defined task after user clicks pause or terminate button.

is_pause_resumed()

Check whether the task was just resumed after a pause. It returns True if the progress is just resumed after it was paused, until the next iteration in which it returns False again. It also returns False in all other cases. This is useful if user wants to repeat current iteration after the work was resumed from pause, especially when the user configured to jump over some customized time-comsuming operations in task() using is_pausing_or_terminating() after the pause button was clicked.

after_started()

Placeholder for user-defined function to be run when the task is started.

after_resumed()

Placeholder for user-defined function to be run when the task is resumed.

after_paused()

Placeholder for user-defined function to be run when the task is paused.

after_terminated()

Placeholder for user-defined function to be run when the task is terminated.

after_completed()

Placeholder for user-defined function to be run when the task is completed.

License

Progresspanel is released under the MIT License. See LICENSE for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

progresspanel-0.1.2.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

progresspanel-0.1.2-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file progresspanel-0.1.2.tar.gz.

File metadata

  • Download URL: progresspanel-0.1.2.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for progresspanel-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c41c23fad3126b0f336e51025d4be193d6ad154705450496db222810f9e43af5
MD5 6e07f5792b0bd7a8930db2aaed16a263
BLAKE2b-256 5eed64bb4a92f88d0117d0ae75eac9f7df9d4484538d698bc3662e0ccdef67d0

See more details on using hashes here.

File details

Details for the file progresspanel-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: progresspanel-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for progresspanel-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 098fb0135ef1a57f71ce95f487572e77cd9ef29d1e24ef79ae8dd5d918b20224
MD5 2fa5219ee40df30c2d08652074cb69df
BLAKE2b-256 19283dee0168118bd0d50c90c3c2b367886cf42cc8b6d34a271ca64e619a4d09

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page