Python 에서 Tkinter 작업표시줄 아이콘 문제

조회수 725회
from tkinter import *
import os

def resource_path(relative_path):
    try:
        base_path = sys._MEIPASS
    except Exception:
        base_path = os.path.abspath(".")
    return os.path.join(base_path, relative_path)

root = Tk()
root.title("제목")
w = 400
h = 100
ws = root.winfo_screenwidth()
hs = root.winfo_screenheight()
x = ws-(w+20)
y = hs-(h+h+h/2)
root.geometry('%dx%d+%d+%d' % (w, h, x, y))
root.resizable(False,False)
root.wm_attributes("-topmost", 1)
src_path = resource_path("icon")
root.iconbitmap(src_path+'/mark.ico')
root.call('wm', 'iconphoto', root._w, PhotoImage(file=src_path+'/mark.png')
Label(root, text="아이콘테스트").pack()
root.mainloop()

위와 같이 작업표시줄 아이콘 넣을려고 했는데 Tclerror 가 발생하네요 파일의 위치는.\icon\mark.ico 하고 .\icon\mark.png 인데 파일 형식이 잘못된건지 코드가 잘못된거지 잘 모르겠습니다.

root.call 부분을 주석처리하면 잘 되네요. 저부분 어디가 잘못된건가요?

오류메세지는

예외가 발생했습니다. TclError
couldn't recognize data in image file "C:\Users\Hojun\Desktop\PythonWorkSpace\icon\mark.ico"
  File "C:\Users\Hojun\Desktop\PythonWorkSpace\test.py", line 42, in <module>
    root.call('wm','iconphoto',root._w,PhotoImage(file=src_path+'\guildmark.ico'))

입니다.

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)