简体   繁体   中英

How to replace the Python logo in a Tkinter-based Python GUI app?

Is there a way to change the default logo, which is the Python logo , that appears in the Window's task bar?

Notice that I have already successfully replaced the default Tk logo that used to appear in my application window.

I am using Windows 7 and Python 2.6 and developing the GUI with the help of Tkinter.

You can do this using the winico Tk extension package. The winico package can also be used to add system tray icons to Tk programs.

The following sample shows one way to do change the runtime application icon. Note that you need to provide a .ico file with suitable sizes of icons in it on the command line and you need to use pythonw. It will not change the taskbar icon for the console when it is running python script. To test this I extracted the winico0.6 package into my python\\tcl\\winico0.6 folder so the package require Winico would work and then ran the code below using pythonw winico_test.py path\\to\\some\\ico\\file.ico .

import sys
from Tkinter import *

def main(argv):
    root = Tk()
    root.update()
    root.tk.call('package','require','Winico')
    id = root.tk.call('winico','createfrom',argv[1])
    root.tk.call('winico','setwindow',root,id,'big',0)
    root.mainloop()
    return 0

if __name__=='__main__':
    sys.exit(main(sys.argv))

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