Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
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.
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.
You can install Progresspanel using pip for the Python environment:
pip install progresspanel
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:
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.
Create a new Progresspanel widget.
Set the total number of iterations for the task.
Set the task function.
Update the progress bar with the current iteration number.
Enable/disable verbose mode to print status updates to the console.
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.
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.
Placeholder for user-defined function to be run when the task is started.
Placeholder for user-defined function to be run when the task is resumed.
Placeholder for user-defined function to be run when the task is paused.
Placeholder for user-defined function to be run when the task is terminated.
Placeholder for user-defined function to be run when the task is completed.
Progresspanel is released under the MIT License. See LICENSE for more information.
FAQs
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.
We found that progresspanel demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.