Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
N3RDIUM committed May 15, 2022
1 parent 666eb44 commit c549c3e
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 3 deletions.
72 changes: 72 additions & 0 deletions PyTaskbar/ProgressAPI.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import ctypes

import comtypes.client as cc
import sys
import warnings


parent_dir = __file__.rsplit("\\", 1)[0]
sys.path.append(parent_dir)
cc.GetModule("./TaskbarLib.tlb")

import comtypes.gen.TaskbarLib as tbl
from comtypes.gen import _683BF642_E9CA_4124_BE43_67065B2FA653_0_1_0
taskbar = cc.CreateObject(
"{56FDF344-FD6D-11d0-958A-006097C9A090}",
interface=tbl.ITaskbarList3)

hWnd = ctypes.windll.kernel32.GetConsoleWindow()
taskbar.ActivateTab(hWnd)

class Progress(object):
def __init__(self,hwnd=hWnd):
super().__init__()
self.initialised = False
self.state = None
self.win = hwnd

def init(self):
self.thisWindow = self.win
taskbar.ActivateTab(self.win)
taskbar.HrInit()
self.state = 'normal'
self.progress = 0
self.initialised = True

def setState(self,value):
if not self.initialised == False:
if value == 'normal':
taskbar.SetProgressState(self.thisWindow,0)
self.state = 'normal'

elif value == 'warning':
taskbar.SetProgressState(self.thisWindow,10)
self.state = 'warning'

elif value == 'error':
taskbar.SetProgressState(self.thisWindow,15)
self.state = 'error'

elif value == 'loading':
taskbar.SetProgressState(self.thisWindow,-15)
self.state = 'loading'

elif value == 'done':
ctypes.windll.user32.FlashWindow(self.thisWindow,True)
self.state = 'done'

else:
warnings.warn('Invalid Argument {} .Please selece one from (normal,warning,error,loading,done).'.format(value))

else:
warnings.warn('Please initialise the object (method:Progress.initialise())')

def setProgress(self,value:int):
if not self.initialised == False:
taskbar.setProgressValue(self.thisWindow,value,100)

elif value>100 or value<0:
warnings.warn('Invalid Argument {} .Please selece one from (<100,>0).'.fromat(value))

else:
warnings.warn('Please initialise the object (method:Progress.initialise())')
Binary file added PyTaskbar/TaskbarLib.tlb
Binary file not shown.
1 change: 1 addition & 0 deletions PyTaskbar/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .ProgressAPI import Progress
1 change: 0 additions & 1 deletion PyTaskbarProgress/readme.md

This file was deleted.

5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def copy_tlb(dst):

setuptools.setup(
name='PyTaskbarProgress',
version='0.0.3',
version='0.0.5',
author='somePythonProgrammer',
description='The ultimate taskbar progress python package!',
packages = setuptools.find_packages(include=['PyTaskbarProgress']),
Expand All @@ -25,11 +25,12 @@ def copy_tlb(dst):
python_requires='>=3.6',
install_requires=[
'comtypes',
'pygetwindow',
'setuptools',
],
include_package_data=True,
url = 'https://github.com/somePythonProgrammer/PyTaskbar',
long_description_content_type='text/markdown',
long_description=open('README.md').read(),
download_url = 'https://github.com/somePythonProgrammer/PyTaskbar/releases/download/0.0.2/PyTaskbarProgress-0.0.2.tar.gz',
download_url = 'https://github.com/somePythonProgrammer/PyTaskbar/releases/download/0.0.5/PyTaskbarProgress-0.0.5.tar.gz',
)

0 comments on commit c549c3e

Please sign in to comment.