TomSchimansky / TomSchimansky/CustomTkinter
CTkProgressBar with windows taskbar
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 13.6k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
It might be nice for the ProgressBar in Windows to be connected to the Windows Taskbar.
Here is some code that would allow you to show the CTkProgressBar progress on the Windows Taskbar
from ctypes import HRESULT, POINTER, Structure, alignment, c_int, c_uint, c_ulong, c_ulonglong, c_ushort, c_wchar_p, sizeof
from ctypes.wintypes import tagRECT
from comtypes import COMMETHOD, GUID, IUnknown, client, wireHWND
WSTRING = c_wchar_p
# values for enumeration 'TBPFLAG'
TBPF_NOPROGRESS = 0
TBPF_INDETERMINATE = 1
TBPF_NORMAL = 2
TBPF_ERROR = 4
TBPF_PAUSED = 8
TBPFLAG = c_int # enum
# values for enumeration 'TBATFLAG'
TBATF_USEMDITHUMBNAIL = 1
TBATF_USEMDILIVEPREVIEW = 2
TBATFLAG = c_int # enum
class tagTHUMBBUTTON(Structure):
_fields_ = [
('dwMask', c_ulong),
('iId', c_uint),
('iBitmap', c_uint),
('hIcon', POINTER(IUnknown)),
('szTip', c_ushort * 260),
('dwFlags', c_ulong)]
class ITaskbarList(IUnknown):
_case_insensitive_ = True
_iid_ = GUID('{56FDF342-FD6D-11D0-958A-006097C9A090}')
_idlflags_ = []
_methods_ = [
COMMETHOD([], HRESULT, 'HrInit'),
COMMETHOD([], HRESULT, 'AddTab',
(['in'], c_int, 'hwnd')),
COMMETHOD([], HRESULT, 'DeleteTab',
(['in'], c_int, 'hwnd')),
COMMETHOD([], HRESULT, 'ActivateTab',
(['in'], c_int, 'hwnd')),
COMMETHOD([], HRESULT, 'SetActivateAlt',
(['in'], c_int, 'hwnd'))]
class ITaskbarList2(ITaskbarList):
_case_insensitive_ = True
_iid_ = GUID('{602D4995-B13A-429B-A66E-1935E44F4317}')
_idlflags_ = []
_methods_ = [
COMMETHOD([], HRESULT, 'MarkFullscreenWindow',
(['in'], c_int, 'hwnd'),
(['in'], c_int, 'fFullscreen'))]
class ITaskbarList3(ITaskbarList2):
_case_insensitive_ = True
_iid_ = GUID('{EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}')
_idlflags_ = []
_methods_ = [
COMMETHOD([], HRESULT, 'SetProgressValue',
(['in'], c_int, 'hwnd'),
(['in'], c_ulonglong, 'ullCompleted'),
(['in'], c_ulonglong, 'ullTotal')),
COMMETHOD([], HRESULT, 'SetProgressState',
(['in'], c_int, 'hwnd'),
(['in'], TBPFLAG, 'tbpFlags')),
COMMETHOD([], HRESULT, 'RegisterTab',
(['in'], c_int, 'hwndTab'),
(['in'], wireHWND, 'hwndMDI')),
COMMETHOD([], HRESULT, 'UnregisterTab',
(['in'], c_int, 'hwndTab')),
COMMETHOD([], HRESULT, 'SetTabOrder',
(['in'], c_int, 'hwndTab'),
(['in'], c_int, 'hwndInsertBefore')),
COMMETHOD([], HRESULT, 'SetTabActive',
(['in'], c_int, 'hwndTab'),
(['in'], c_int, 'hwndMDI'),
(['in'], TBATFLAG, 'tbatFlags')),
COMMETHOD([], HRESULT, 'ThumbBarAddButtons',
(['in'], c_int, 'hwnd'),
(['in'], c_uint, 'cButtons'),
(['in'], POINTER(tagTHUMBBUTTON), 'pButton')),
COMMETHOD([], HRESULT, 'ThumbBarUpdateButtons',
(['in'], c_int, 'hwnd'),
(['in'], c_uint, 'cButtons'),
(['in'], POINTER(tagTHUMBBUTTON), 'pButton')),
COMMETHOD([], HRESULT, 'ThumbBarSetImageList',
(['in'], c_int, 'hwnd'),
(['in'], POINTER(IUnknown), 'himl')),
COMMETHOD([], HRESULT, 'SetOverlayIcon',
(['in'], c_int, 'hwnd'),
(['in'], POINTER(IUnknown), 'hIcon'),
(['in'], WSTRING, 'pszDescription')),
COMMETHOD([], HRESULT, 'SetThumbnailTooltip',
(['in'], c_int, 'hwnd'),
(['in'], WSTRING, 'pszTip')),
COMMETHOD([], HRESULT, 'SetThumbnailClip',
(['in'], c_int, 'hwnd'),
(['in'], POINTER(tagRECT), 'prcClip'))]
assert sizeof(tagTHUMBBUTTON) in [540, 552], sizeof(tagTHUMBBUTTON)
assert alignment(tagTHUMBBUTTON) in [4, 8], alignment(tagTHUMBBUTTON)
taskbar = client.CreateObject('{56FDF344-FD6D-11d0-958A-006097C9A090}', interface=ITaskbarList3)
taskbar.HrInit()
hwnd = int(root.wm_frame(), 16)
taskbar.ActivateTab(hwnd)
taskbar.SetProgressState(hwnd, TBPF_NORMAL)
taskbar.SetProgressValue(hwnd, int(50),100)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided Windows taskbar integration example, especially the ITaskbarList3 definitions and the root.wm_frame() handle. Determine how CTkProgressBar exposes its progress and how Windows-only behavior should fit the existing UI. Done means a Windows CTkProgressBar can update the taskbar progress without affecting other platforms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- desktop
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100