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.pn
g 인데 파일 형식이 잘못된건지 코드가 잘못된거지 잘 모르겠습니다.
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'))
입니다.
-
(•́ ✖ •̀)
알 수 없는 사용자 - 〉
댓글 입력