In fact, the iconbitmap function can only accept a file name as an argument, so there should be a file there. You can make the Base64 version of the icon (string version) via the link, download the file and copy the result to the source file as a variable string. Extract it to a temporary file, and finally transfer this file to iconbitmap and delete it. It is pretty simple:
import base64
import os
from Tkinter import *
icon = \
""" REPLACE THIS WITH YOUR BASE64 VERSION OF THE ICON
"""
icondata= base64.b64decode(icon)
tempFile= "icon.ico"
iconfile= open(tempFile,"wb")
iconfile.write(icondata)
iconfile.close()
root = Tk()
root.wm_iconbitmap(tempFile)
os.remove(tempFile)
Hope this helps!
source
share