Tkinter, how to use the same script in win and llinux without the window icon disturbing [duplicate]

0

I've been writing scripts in Win VS and when I switched to Linux, I came across the following problem: When I use an image as a window icon in Linux (which does not have the same) the script does not execute.

How can I "detect" the OS so it does not use this feature in Linux distributions, avoiding the error?

Example:

from tkinter import *

win = Tk()
win.title("teste")
#problema - mas e no Linux?
win.iconbitmap("logo.ico")

winLabel = Label(win, text="Isso é um teste").place(x=50, y=50)
win.resizable(width=False, height=False)
win.geometry("200x200")
win.mainloop()
    
asked by anonymous 20.06.2018 / 19:22

1 answer

-1

Try using exception handling by replacing:

win.iconbitmap("logo.ico")

by:

try:
    win.iconbitmap("logo.ico")
except:
    pass
    
20.06.2018 / 20:16