1

I have tried the following code to change the default Tk logo in the upper left corner:

import Tkinter as Tkinter

class window(Tkinter.Tk):
    def __init__(self,parent):
        Tkinter.Tk.__init__(self,parent)
        self.parent = parent
        self.iconbitmap(default='Logo.ico') 
        self.initialize()


    def initialize(self):
        self.grid()

if __name__ == "__main__":
    app = window(None)
    app.title('Window')
    app.mainloop()

The problem is that it does nothing.. no error message and no logo change. Logo.ico is a file in the same directory as the script.

John Crow
  • 927
  • 3
  • 13
  • 26
  • see: http://stackoverflow.com/questions/550050/removing-the-tk-icon-on-python-tkinter-windows answer should help. – W1ll1amvl Sep 16 '14 at 02:49
  • @W1ll1amvl Yes I saw that thanks. This works fine for me but not when I put it in a class as above. I must be doing something syntactically wrong but I'm not sure what. – John Crow Sep 16 '14 at 02:53
  • 1
    Ok, so I tried this on python 3, windows, (obviously changing Tkinter to tkinter) and everything worked fine. Maybe the computer you are on has something to do with it. – W1ll1amvl Sep 16 '14 at 04:08
  • 1
    i just tried this in python 2.7.6 without any modification and used the python logo (renamed) this worked fine, are you sure there is nothing wrong with your icon file? – James Kent Sep 16 '14 at 06:19
  • @W1ll1amvl Ah yes that seems to be the case. I have no idea why but this works on my laptop but not on my PC. Both run windows 7 with the same version of python. Weird. Thanks. – John Crow Sep 16 '14 at 10:09
  • I could **not** reproduce the problem on a PC with: `OS: Windows-7-6.1.7601-SP1 (32-bit), Python: 2.7.3`. It works as expected. Try supplying another icon file, maybe the one you use has some problem? – Fenikso Sep 16 '14 at 12:06
  • @Fenikso Thanks fr trying. It turns out that it must be an install issue on my PC because it worked well on my laptop. I'll add an answer now. – John Crow Sep 16 '14 at 13:06

1 Answers1

2

So it turns out that what I posted is the correct syntax. There seems to be an issue with the python install on my desktop PC because the code works perfectly on my laptop. I guess it's time for a reinstallation.

John Crow
  • 927
  • 3
  • 13
  • 26