Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
282 views
in Technique[技术] by (71.8m points)

python - Using Windows 7 taskbar features in PyQt

I am looking for information on the integration of some of the new Windows 7 taskbar features into my PyQt applications.

Specifically if there already exists the possibility to use the new progress indicator (see here) and the quick links (www.petri.co.il/wp-content/uploads/new_win7_taskbar_features_8.gif).

If anyone could provide a few links or just a "not implemented yet", I'd be very grateful.

Thanks a lot.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As quark said, the functionality is not in Qt 4.5, but you can call the windows API directly from Qt. Its a little bit of work though.

  1. The new taskbar API is exposed through COM, so you can't use ctypes.windll . You need to create a .tlb file to access the functions. Get the interface definition for ITaskbarList from this forum post , or from the windows SDK. Save it to a file called e.g. TaskbarLib.idl .

  2. Create the .tlb file. You'll probably need the Windows SDK, or get an IDL compiler from somewhere else.

    midl TaskbarLib.idl /tlb TaskbarLib.tlb
    
  3. Load the .tlb (you need the Win32 Extensions for Python, http://python.net/crew/skippy/win32/Downloads.html):

    import comtypes.client as cc
    cc.GetModule("TaskbarLib.tlb")
    
  4. Create the TaskbarList object. The function for setting the progress bar is in the interface ITaskbarList3:

    import comtypes.gen.TaskbarLib as tbl
    taskbar = cc.CreateObject(
        "{56FDF344-FD6D-11d0-958A-006097C9A090}",
        interface=tbl.ITaskbarList3)
    
  5. Now you can call the API functions:

    taskbar.HrInit()
    taskbar.SetProgressValue(self.winId(),40,100)
    

Here's a complete example script. Sources: 1 2


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...