Python Forum
[Tkinter] Tkinter Logo Image - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: [Tkinter] Tkinter Logo Image (/thread-27072.html)



Tkinter Logo Image - Evil_Patrick - May-25-2020

So I'm Trying to Create a Tkinter window and it has an icon in same folder but if I upload it on Github or change dir then it will show an error because of icon location
Is there any solution for it?

PS - Sorry for Bad Explanation LOL

from tkinter import *

root = Tk()
root.title('Password Generator')
root.geometry('350x300+400+200')
root.resizable(height=FALSE,width=FALSE)
root.iconbitmap(r"C:\Users\Evil Patrick\Desktop\Python\projects\logo.ico")

root.mainloop()



RE: Tkinter Logo Image - DT2000 - May-25-2020

I don't think you are being clear on your explanation. Please try to express it a little differently so you can receive the information and help you need.

If your logo.ico is in a different location than your python code you would require the direct path to its location in order for it to be used. If you have your logo.ico in the same folder as your python code it will display just fine as shown in the example below, which does not require the full path being used.

from tkinter import *
 
root = Tk()
root.title('Password Generator')
root.geometry('350x300+400+200')
root.resizable(height=FALSE,width=FALSE)
root.iconbitmap(root.wm_iconbitmap('logo.ico')
 
root.mainloop()