PYQT taskbar icon Issues

Source: Internet
Author: User

Today when running a PYQT program found that the function of Setwindowicon half of the role, learn QT know this function at the same time set the program's two places icon display,

First in the upper left corner of the program a small icon (only useful for Windows and Linux,mac not), the second is the taskbar icon, such as:



When you use PYQT, you find that only the first settings are successful, and the second one shows the Pythonw.exe icon.

Google looked for a bit, solved, the following is a detailed description, English slightly worse students directly see the solution, say Bo Master's English is a rotten mess

I ' ve found the answer, after some digging.

in windows 7, the taskbar is not for" application windows "per se, it's for" Application U Ser Models ". For example, if you have several different instances of your application running, and each instance had its own icon, then They'll all is grouped under a single taskbar icon. Windows uses various heuristics to decide whether different instances should is grouped or not, and the this case it decide D that everything hosted by Pythonw.exe should is grouped under the icon for Pythonw.exe.

The correct solution is for Pythonw.exe to tell Windows it was merely hosting other applications. Perhaps a future release of Python would do this. Alternatively, you can add a registry key to tell Windows this Pythonw.exe is just a host rather than an application in it s own right. See MSDN documentation Forappusermodelids.

Alternatively, you can use a Windows-from-Python, to explicitly-tell-windows what the correct appusermodelid are for T His process:

In short, my understanding is that PYQT is going to explain to Python that Windows recognizes Python when it runs, and that the program you write is considered a subroutine of the main program of Python, and you're going to stand up and tell windows, I force this window to use a separate appusermodelid, and now this window has a new resource to dominate, more customizable.

If my understanding is wrong, please leave a message.

So how do you tell windows:

Import Ctypesctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID ("Myappid")

The above applies only to Windows,

But if you unfortunately use Linux what to do, in fact, it is easier to use Ubuntu know every desktop software in the/usr/share/applications directory under the corresponding icon file. desktop

When your software is ready to be packaged, you can automatically add such a file.

Of course, with C++&QT students will not encounter such a problem.

PYQT taskbar icon Issues

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.