How do I set my app's associated files' icon?



  • I googled and only returned app icon stuff, which I already have set. I mean the pickle file I'm using to store my data (Python 3.x, PyQt5). How do I put an icon on it so that it works on all the different platforms, or at a minimum just Windows 10?

    If I'm not being clear enough, you know how .py files open with python usually, and each .py file in the explorer file manager has an icon which looks like two snakes, one blue, one yellow. I want an icon that is instead a bundle of bananas. Or this might be the Notepad++ chameleon, or something else depending on what you have set in windows. But I don't want the user to have to set this on their own, it should just work.

    Thanks.


  • Lifetime Qt Champion

    Hi,

    That's something you'll have to do through an installer for your application. For example, see here for Windows.



  • Hi, @SGaist

    I have written an installer for my app in PyQt5. It's really beautiful and links you to a LaTeX backend to install if you don't already have one.

    I will see how to call these functions you linked to and post the solution here.



  • @SGaist

    Couldn't get that to work.

    I've manually edited my registry per the instructions.

    0_1557283886186_7f4281fa-5fc7-4bfe-8f38-84b0a5fee7ba-image.png

    And called this my python app's main function:

    from win32com.shell import shell, shellcon
    shell.SHChangeNotify(shellcon.SHCNE_ASSOCCHANGED, shellcon.SHCNF_IDLIST, None, None)  
    

    There is still the defualt icon (white paper) as the icon on my banana_cats_debug.🍌😹 file. Yes that's the extension a banana and a cat. Hey the registry editor let me enter it!



  • @enjoysmath
    The entry in that list should (normally) be either .extension (i.e. with a leading dot) or a prog-id. Hard to read, but you don't seem to have either of those, given it's at the end of the list.

    Fairly obviously, the first thing to test out for POC is that it works on a regular extension like .xyz. Only after that try with your weird banana-cat sequence, which may or may not work, I don't know what those characters actually are.

    P.S.
    I have cat, and I can tell you that cats have no interest at all in bananas.



  • @JonB Thanks. Which list, the tree view or the data items on the right? Cats is short hand for "categories". And there's an internet meme about placing a banana peel on your cat. And apple computer - fruit - so banana. I think it's a better name idea than functional: "Catgory Diagram Editor" I don't really think is a good name.



  • @enjoysmath said in How do I set my app's associated files' icon?:

    Which list, the tree view or the data items on the right?

    Where it appears at the end of the treeview. If it has a leading dot it should be near the beginning, where all the other dot-extensions are. Does yours even have a leading dot, like I asked? Have you tested POC with a "normal" .xyz first?



  • @JonB I opened up the regeditor and that's where I find it, at the end of the .ext section. I know in the screen shot it's not, but maybe the regedit has to sort them or something.

    I tried with .ban extension and same result. However, I tried my normal unicode extension and from windows explorer shell (context menu) did "open with.." notepad++ and it successfully assigned an icon. So, there should be no problem theoretically with my special unicode chars at least on windows.

    Still not working.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.