简体   繁体   English

在PyQt中使用Windows 7任务栏功能

[英]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. 我正在寻找有关将一些新的Windows 7任务栏功能集成到我的PyQt应用程序中的信息。

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). 具体来说,如果已经存在使用新进度指示器( 参见此处 )和快速链接(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. 非常感谢。

As quark said, the functionality is not in Qt 4.5, but you can call the windows API directly from Qt. 正如夸克所说,功能不在Qt 4.5中,但你可以直接从Qt调用windows API。 Its a little bit of work though. 虽然它有点工作。

  1. The new taskbar API is exposed through COM, so you can't use ctypes.windll . 新的任务栏API通过COM公开,因此您无法使用ctypes.windll。 You need to create a .tlb file to access the functions. 您需要创建一个.tlb文件来访问这些函数。 Get the interface definition for ITaskbarList from this forum post , or from the windows SDK. 从此论坛帖子或从Windows SDK获取ITaskbarList的接口定义。 Save it to a file called eg TaskbarLib.idl . 将其保存到名为TaskbarLib.idl的文件中。

  2. Create the .tlb file. 创建.tlb文件。 You'll probably need the Windows SDK, or get an IDL compiler from somewhere else. 您可能需要Windows SDK,或从其他地方获取IDL编译器。

     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 ): 加载.tlb(你需要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. 创建TaskbarList对象。 The function for setting the progress bar is in the interface ITaskbarList3: 设置进度条的功能在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: 现在您可以调用API函数:

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

Here's a complete example script . 这是一个完整的示例脚本 Sources: 1 2 资料来源: 1 2

There is a Qt add-on that implements all the Windows 7 taskbar extensions. 有一个Qt附加组件实现了所有Windows 7任务栏扩展。 It is called Q7Goodies . 它被称为Q7Goodies It comes with a PyQt bindings, so this is probably the easiest way to take advantage of Windows 7 features in PyQt. 它带有PyQt绑定,因此这可能是利用PyQt中Windows 7功能的最简单方法。

Not implemented in Qt 4.5, but in the works for Qt 4.6 it appears. 没有在Qt 4.5中实现,但是在Qt 4.6的工作中它出现了。 PyQt won't wrap 4.6 until Qt 4.6 is officially released, but you can play with the 4.6 snapshot s or checkout the Qt repository and see if the C++ version supports the features you want. 在Qt 4.6正式发布之前,PyQt不会包装4.6,但您可以使用4.6快照或签出Qt存储库 ,看看C ++版本是否支持您想要的功能。 If it does then PyQt 4.6 will support it as well. 如果确实如此,那么PyQt 4.6也会支持它。

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. 补充: 4.6功能列表没有显示明确的Windows 7支持,但这并不意味着它没有你想要的,因为,至少如果我理解正确,它可能会将该功能折叠到现有小部件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM