Show progress on taskbar icon
Asked Answered
M

2

10

I placed a progressbar in my tkinter GUI but it is not showing the progress on the taskbar icon. Like when I copy and paste in Windows: Windows File Explorer progressbar

How can I implement this in my Tkinter GUI?

This is my code:

from tkinter import *
from tkinter import ttk
    
root = Tk()
    
progressbar = ttk.Progressbar(orient=HORIZONTAL, length=200, mode='determinate')
progressbar.pack(side="bottom")
progressbar.start()
    
root.mainloop()

Currently, the progress bar looks like this:

No taskbar progress

How to add progress behind the icon on the Windows taskbar?

Using Python 3.

Magnetomotive answered 15/10, 2018 at 5:35 Comment(10)
Possible duplicate of Python + Tkinter Windows 7 taskbar progressTrantrance
I see you're using windows 10 but this will hopefully still help.Trantrance
@ArtemisFowl I am neither using Windows 10 nor 7 . I am using Windows 8.Magnetomotive
Ah, sorry. In any case, does linked question help?Trantrance
@ArtemisFowl I receive this error: dpaste.com/2BV4V5RMagnetomotive
64 bit or 32 bit?Trantrance
@ArtemisFowl 64 bit.Magnetomotive
Are you using a 32 bit DLL?Trantrance
No.............Magnetomotive
Tru using github.com/N3RDIUM/PyTaskbarClaritaclarity
A
0

I believe you have to use a window API, such as win32taskbar, and link it to a function you create and name it e.g update_progress. Then, take the progress from the taskbar, and update it. Here is an example:

win32taskbar.SetProgressValue(win32gui.GetForegroundWindow(), progress, 100)

progress = 0
while progress <= 100:
    progress += 1
    progressbar['value'] = progress
    update_progress(progress)
    root.update_idletasks()
    root.after(100)  # Adjust the delay as needed
Angara answered 7/5 at 19:6 Comment(0)
U
0

You can use a python package called PyTaskbar. Install using pip:

python -m pip install PyTaskbarProgress

First, you have to provide the progress of the progress bar by modifying your code as follows:

from tkinter import *
from tkinter import ttk
import time
import PyTaskbar

root = Tk()
progressbar = ttk.Progressbar(orient=HORIZONTAL, length=200, mode='determinate')
progressbar.pack(side="bottom")
progressbar.start()

progress = PyTaskbar.Progress()
progress.init()
progress.setState('loading')

while progressbar['value'] != 100:
    progress.setProgress(progressbar['value'])
    time.sleep(0.05)

prog.setState('done')
    
root.mainloop()
Uriah answered 12/7 at 14:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.