Python easygui edit icon

49 Views Asked by At

I am currently working on a program in python using easygui, but I need to change the feather icon to the icon of the company I am currently working in.

I've found this post already: Python EasyGUI Changing Taskbar Icon

The thing is, I am using diropenbox, ynbox and msgbox as well, and these seem to work differently than the choicebox and buttonbox when I look into the "derived_boxes.py" and "diropen_box.py" files. Has anyone some kind of advice on how edit the files so I can change the icon here as well? Thank you so much!!

1

There are 1 best solutions below

1
On

I was able to solve it myself, it's actually quite simple with the "derived_boxes.py" file, you just got to add one line in the correct place in the "fillable_box.py" file which is in the same directory:

...
def __fillablebox(msg, title="", default="", mask=None, image=None, root=None):
    """
    Show a box in which a user can enter some text.
    You may optionally specify some default text, which will appear in the
    enterbox when it is displayed.
    Returns the text that the user entered, or None if they cancel the 
    operation.
    """

    global boxRoot, __enterboxText, __enterboxDefaultText
    global cancelButton, entryWidget, okButton

    if title is None:
        title = ""
    if default is None:
        default = ""
    __enterboxDefaultText = default
    __enterboxText = __enterboxDefaultText

    if root:
        root.withdraw()
        boxRoot.withdraw()
    else:
        boxRoot = tk.Tk()
        boxRoot.iconbitmap("put\the\directory\of\the\.ico\file\here") #add this line
        boxRoot.withdraw()

...

For the "diropen_box.py" file you have to add

localRoot.iconbitmap("put\the\directory\of\the\.ico\file\here")

to the def diropenbox function. I've put it here:

...
title = ut.getFileDialogTitle(msg, title)
localRoot = tk.Tk()
localRoot.iconbitmap("put\the\directory\of\the\.ico\file\here") #icon of the messagebox
localRoot.withdraw()
localRoot.lift()
...

But be aware, that you change the default icon in general with this method, so be careful when using this in a different program!