简体   繁体   中英

Python - TkInter Icon & GUI

I've been starting to learn python recently and have spent several hours trying to find a way to set a custom icon for the application however all the results that I find are either outdated or incompatible with Mac. Is there a working example for all platforms that I can use? A custom GUI is not on the top of priorities but if there is a documentation that I haven't found I would be very grateful if someone could show me.

Edit:

Just a quick summary of Jonah very kindly provided:

  1. Download get-pip.py here
  2. Run get-pip.py from terminal using: "python get-pip.py"
  3. Install py2app with: "pip install -U py2app"

    Note!

    This may not apply to everyone but I have to use: "pip3 install -U py2app"

  4. Use and download configuration similar to this

  5. Convert your file to a .icns at this site
  6. Set the filepaths in the setup.py according to your .py script and your icns image.
  7. Run the setup.py with: "python setup.py py2app"
  8. Locate your app in the dist folder that was created :)

Ok. So to add an icon from memory you have to make a .icns file. Follow these or these instructions. Secondly you have to make the program into an app. To do this follow the instructions here but don't do it yet. Ok now go into setup.py and add under options 'iconfile' : 'icon.icns' . Create the app now. It will only work if you put the icns image in the same folder as setup.py. This will add both a icon to the app and the top corner where the Tkinter logo shows on Windows.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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