Using Windows 7 taskbar features in PyQt

后端 未结 3 567
面向向阳花
面向向阳花 2020-12-04 23:10

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 pos

相关标签:
3条回答
  • 2020-12-04 23:13

    There is a Qt add-on that implements all the Windows 7 taskbar extensions. It is called Q7Goodies. It comes with a PyQt bindings, so this is probably the easiest way to take advantage of Windows 7 features in PyQt.

    0 讨论(0)
  • 2020-12-04 23:25

    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

    0 讨论(0)
  • 2020-12-04 23:31

    Not implemented in Qt 4.5, but in the works for Qt 4.6 it appears. PyQt won't wrap 4.6 until Qt 4.6 is officially released, but you can play with the 4.6 snapshots or checkout the Qt repository and see if the C++ version supports the features you want. If it does then PyQt 4.6 will support it as well.

    Added: The list of 4.6 features doesn't show explicit Windows 7 support, but that doesn't mean it won't have what you want, since, at least if I understand correctly, its likely they would fold that functionality into the existing widget.

    0 讨论(0)
提交回复
热议问题