tkinter 제목 옆의 아이콘을 코드에 포함하는 방법
9461 단어 Tkinter파이썬PyInstaller아이콘
파이썬 바탕 화면 아이콘을 변경하는 방법
python의 데스크탑 아이콘은 보통 pyinstaller를 사용하면,
pyinstallerpyinstaller ソース.py --icon=アイコンファイル.ico
에서 변경할 수 있습니다.
하지만 tkinter로 창을 만들 때,
변경할 수 없습니다.
여기도 변경하고 싶다.
iconbitmap을 사용하는 방법
icon.ico를 만드는 경우,
ico.pyimport tkinter as tk
root = tk.Tk()
tk.iconbitmap(default='icon.ico')
root.mainloop()
그러면 같은 폴더에 있는 icon.ico가 표시됩니다.
그러나 pyinstaller에서 --onefile을 지정하여 컴파일해도 동일한 파일로 컴파일되지 않고 icon.ico 파일을 동일한 폴더에 준비해야합니다. 이것은 조금 나쁘다.
아이콘을 코드에 포함
아이콘을 base64로 인코딩하고 포함하는 방법이 있습니다. 먼저 이미지 파일(a.gif)을 준비합니다. (gif 피알이 좋은 것 같습니다.)
이것을 base64로 인코딩하기 위해 Windows PowerSell을 시작하고,
certutilcertutil -encode a.gif text.txt
그렇다면 같은 폴더에 text.txt라는 파일을 만들 수 있습니다. 내용은,
certutil-----BEGIN CERTIFICATE-----
R0lGODlhEAAQAPcAAAAAAAAAMwAAZgAAmQAAzAAA/wArAAArMwArZgArmQArzAAr
/wBVAABVMwBVZgBVmQBVzABV/wCAAACAMwCAZgCAmQCAzACA/wCqAACqMwCqZgCq
mQCqzACq/wDVAADVMwDVZgDVmQDVzADV/wD/AAD/MwD/ZgD/mQD/zAD//zMAADMA
MzMAZjMAmTMAzDMA/zMrADMrMzMrZjMrmTMrzDMr/zNVADNVMzNVZjNVmTNVzDNV
/zOAADOAMzOAZjOAmTOAzDOA/zOqADOqMzOqZjOqmTOqzDOq/zPVADPVMzPVZjPV
mTPVzDPV/zP/ADP/MzP/ZjP/mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YrAGYr
M2YrZmYrmWYrzGYr/2ZVAGZVM2ZVZmZVmWZVzGZV/2aAAGaAM2aAZmaAmWaAzGaA
/2aqAGaqM2aqZmaqmWaqzGaq/2bVAGbVM2bVZmbVmWbVzGbV/2b/AGb/M2b/Zmb/
mWb/zGb//5kAAJkAM5kAZpkAmZkAzJkA/5krAJkrM5krZpkrmZkrzJkr/5lVAJlV
M5lVZplVmZlVzJlV/5mAAJmAM5mAZpmAmZmAzJmA/5mqAJmqM5mqZpmqmZmqzJmq
/5nVAJnVM5nVZpnVmZnVzJnV/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwAM8wAZswA
mcwAzMwA/8wrAMwrM8wrZswrmcwrzMwr/8xVAMxVM8xVZsxVmcxVzMxV/8yAAMyA
M8yAZsyAmcyAzMyA/8yqAMyqM8yqZsyqmcyqzMyq/8zVAMzVM8zVZszVmczVzMzV
/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8Amf8AzP8A//8rAP8rM/8rZv8r
mf8rzP8r//9VAP9VM/9VZv9Vmf9VzP9V//+AAP+AM/+AZv+Amf+AzP+A//+qAP+q
M/+qZv+qmf+qzP+q///VAP/VM//VZv/Vmf/VzP/V////AP//M///Zv//mf//zP//
/wAAAAAAAAAAAAAAACH5BAEAAPwALAAAAAAQABAAAAh7APcJHEiwoMGDCAXWU8aQ
mDKCDRlmYsgQorKF0JQR26exYSaBkz46pHgRWr2BysQIZLhwJUeN+9A85Diyo0Zo
+8TcQJmxIs6VAD4qdLhv4UmBYmIUJFlxHzEAGwlunDkwxs6lTqPuywRgJlVlPwfq
LBq26MOeMRNSTRgQADs=
-----END CERTIFICATE-----
라는 내용의 파일을 할 수 있습니다. 이 문자의 배열 부분을 가져와 코드에 포함합니다.
base64.pyimport tkinter as tk
root = tk.Tk()
data = '''R0lGODlhEAAQAPcAAAAAAAAAMwAAZgAAmQAAzAAA/wArAAArMwArZgArmQArzAAr
/wBVAABVMwBVZgBVmQBVzABV/wCAAACAMwCAZgCAmQCAzACA/wCqAACqMwCqZgCq
mQCqzACq/wDVAADVMwD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wlunDkwxs6lTqPuywRgJlVlPwfq
LBq26MOeMRNSTRgQADs=
'''
img = tk.PhotoImage(data=data)
label = tk.Label(image=img)
label.pack()
root.mainloop()
그렇다면,
↑와 같은 코드 임베디드 이미지를 표시할 수 있습니다.
제목 옆의 아이콘을 코드에 삽입하는 방법
여기까지 오면, 조금입니다. 지금 묻은 이미지를 제목 옆에 표시해 주면 됩니다. 여기에서
title.pyroot.tk.call('wm', 'iconphoto', root._w, tk.PhotoImage(data=data))
를 사용하여 아이콘을 표시합니다.
title.pyimport tkinter as tk
root = tk.Tk()
data = '''R0lGODlhEAAQAPcAAAAAAAAAMwAAZgAAmQAAzAAA/wArAAArMwArZgArmQArzAAr
/wBVAABVMwBVZgBVmQBVzABV/wCAAACAMwCAZgCAmQCAzACA/wCqAACqMwCqZgCq
mQCqzACq/wDVAADVMwDVZgDVmQDVzADV/wD/AAD/MwD/ZgD/mQD/zAD//zMAADMA
MzMAZjMAmTMAzDMA/zMrADMrMzMrZjMrmTMrzDMr/zNVADNVMzNVZjNVmTNVzDNV
/zOAADOAMzOAZjOAmTOAzDOA/zOqADOqMzOqZjOqmTOqzDOq/zPVADPVMzPVZjPV
mTPVzDPV/zP/ADP/MzP/ZjP/mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YrAGYr
M2YrZmYrmWYrzGYr/2ZVAGZVM2ZVZmZVmWZVzGZV/2aAAGaAM2aAZmaAmWaAzGaA
/2aqAGaqM2aqZmaqmWaqzGaq/2bVAGbVM2bVZmbVmWbVzGbV/2b/AGb/M2b/Zmb/
mWb/zGb//5kAAJkAM5kAZpkAmZkAzJkA/5krAJkrM5krZpkrmZkrzJkr/5lVAJlV
M5lVZplVmZlVzJlV/5mAAJmAM5mAZpmAmZmAzJmA/5mqAJmqM5mqZpmqmZmqzJmq
/5nVAJnVM5nVZpnVmZnVzJnV/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwAM8wAZswA
mcwAzMwA/8wrAMwrM8wrZswrmcwrzMwr/8xVAMxVM8xVZsxVmcxVzMxV/8yAAMyA
M8yAZsyAmcyAzMyA/8yqAMyqM8yqZsyqmcyqzMyq/8zVAMzVM8zVZszVmczVzMzV
/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8Amf8AzP8A//8rAP8rM/8rZv8r
mf8rzP8r//9VAP9VM/9VZv9Vmf9VzP9V//+AAP+AM/+AZv+Amf+AzP+A//+qAP+q
M/+qZv+qmf+qzP+q///VAP/VM//VZv/Vmf/VzP/V////AP//M///Zv//mf//zP//
/wAAAAAAAAAAAAAAACH5BAEAAPwALAAAAAAQABAAAAh7APcJHEiwoMGDCAXWU8aQ
mDKCDRlmYsgQorKF0JQR26exYSaBkz46pHgRWr2BysQIZLhwJUeN+9A85Diyo0Zo
+8TcQJmxIs6VAD4qdLhv4UmBYmIUJFlxHzEAGwlunDkwxs6lTqPuywRgJlVlPwfq
LBq26MOeMRNSTRgQADs=
'''
root.tk.call('wm', 'iconphoto', root._w, tk.PhotoImage(data=data))
root.mainloop()
실행하면,
라는 바람이 됩니다.
이제 pyinstaller로 설치하더라도 icon.ico를 넣을 필요없이 하나의 파일로 시작할 수 있습니다.
Reference
이 문제에 관하여(tkinter 제목 옆의 아이콘을 코드에 포함하는 방법), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/Dr_Thomas/items/f3b2eff79cba10eb42a3
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
pyinstaller ソース.py --icon=アイコンファイル.ico
icon.ico를 만드는 경우,
ico.py
import tkinter as tk
root = tk.Tk()
tk.iconbitmap(default='icon.ico')
root.mainloop()
그러면 같은 폴더에 있는 icon.ico가 표시됩니다.
그러나 pyinstaller에서 --onefile을 지정하여 컴파일해도 동일한 파일로 컴파일되지 않고 icon.ico 파일을 동일한 폴더에 준비해야합니다. 이것은 조금 나쁘다.
아이콘을 코드에 포함
아이콘을 base64로 인코딩하고 포함하는 방법이 있습니다. 먼저 이미지 파일(a.gif)을 준비합니다. (gif 피알이 좋은 것 같습니다.)
이것을 base64로 인코딩하기 위해 Windows PowerSell을 시작하고,
certutilcertutil -encode a.gif text.txt
그렇다면 같은 폴더에 text.txt라는 파일을 만들 수 있습니다. 내용은,
certutil-----BEGIN CERTIFICATE-----
R0lGODlhEAAQAPcAAAAAAAAAMwAAZgAAmQAAzAAA/wArAAArMwArZgArmQArzAAr
/wBVAABVMwBVZgBVmQBVzABV/wCAAACAMwCAZgCAmQCAzACA/wCqAACqMwCqZgCq
mQCqzACq/wDVAADVMwDVZgDVmQDVzADV/wD/AAD/MwD/ZgD/mQD/zAD//zMAADMA
MzMAZjMAmTMAzDMA/zMrADMrMzMrZjMrmTMrzDMr/zNVADNVMzNVZjNVmTNVzDNV
/zOAADOAMzOAZjOAmTOAzDOA/zOqADOqMzOqZjOqmTOqzDOq/zPVADPVMzPVZjPV
mTPVzDPV/zP/ADP/MzP/ZjP/mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YrAGYr
M2YrZmYrmWYrzGYr/2ZVAGZVM2ZVZmZVmWZVzGZV/2aAAGaAM2aAZmaAmWaAzGaA
/2aqAGaqM2aqZmaqmWaqzGaq/2bVAGbVM2bVZmbVmWbVzGbV/2b/AGb/M2b/Zmb/
mWb/zGb//5kAAJkAM5kAZpkAmZkAzJkA/5krAJkrM5krZpkrmZkrzJkr/5lVAJlV
M5lVZplVmZlVzJlV/5mAAJmAM5mAZpmAmZmAzJmA/5mqAJmqM5mqZpmqmZmqzJmq
/5nVAJnVM5nVZpnVmZnVzJnV/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwAM8wAZswA
mcwAzMwA/8wrAMwrM8wrZswrmcwrzMwr/8xVAMxVM8xVZsxVmcxVzMxV/8yAAMyA
M8yAZsyAmcyAzMyA/8yqAMyqM8yqZsyqmcyqzMyq/8zVAMzVM8zVZszVmczVzMzV
/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8Amf8AzP8A//8rAP8rM/8rZv8r
mf8rzP8r//9VAP9VM/9VZv9Vmf9VzP9V//+AAP+AM/+AZv+Amf+AzP+A//+qAP+q
M/+qZv+qmf+qzP+q///VAP/VM//VZv/Vmf/VzP/V////AP//M///Zv//mf//zP//
/wAAAAAAAAAAAAAAACH5BAEAAPwALAAAAAAQABAAAAh7APcJHEiwoMGDCAXWU8aQ
mDKCDRlmYsgQorKF0JQR26exYSaBkz46pHgRWr2BysQIZLhwJUeN+9A85Diyo0Zo
+8TcQJmxIs6VAD4qdLhv4UmBYmIUJFlxHzEAGwlunDkwxs6lTqPuywRgJlVlPwfq
LBq26MOeMRNSTRgQADs=
-----END CERTIFICATE-----
라는 내용의 파일을 할 수 있습니다. 이 문자의 배열 부분을 가져와 코드에 포함합니다.
base64.pyimport tkinter as tk
root = tk.Tk()
data = '''R0lGODlhEAAQAPcAAAAAAAAAMwAAZgAAmQAAzAAA/wArAAArMwArZgArmQArzAAr
/wBVAABVMwBVZgBVmQBVzABV/wCAAACAMwCAZgCAmQCAzACA/wCqAACqMwCqZgCq
mQCqzACq/wDVAADVMwDVZgDVmQDVzADV/wD/AAD/MwD/ZgD/mQD/zAD//zMAADMA
MzMAZjMAmTMAzDMA/zMrADMrMzMrZjMrmTMrzDMr/zNVADNVMzNVZjNVmTNVzDNV
/zOAADOAMzOAZjOAmTOAzDOA/zOqADOqMzOqZjOqmTOqzDOq/zPVADPVMzPVZjPV
mTPVzDPV/zP/ADP/MzP/ZjP/mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YrAGYr
M2YrZmYrmWYrzGYr/2ZVAGZVM2ZVZmZVmWZVzGZV/2aAAGaAM2aAZmaAmWaAzGaA
/2aqAGaqM2aqZmaqmWaqzGaq/2bVAGbVM2bVZmbVmWbVzGbV/2b/AGb/M2b/Zmb/
mWb/zGb//5kAAJkAM5kAZpkAmZkAzJkA/5krAJkrM5krZpkrmZkrzJkr/5lVAJlV
M5lVZplVmZlVzJlV/5mAAJmAM5mAZpmAmZmAzJmA/5mqAJmqM5mqZpmqmZmqzJmq
/5nVAJnVM5nVZpnVmZnVzJnV/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwAM8wAZswA
mcwAzMwA/8wrAMwrM8wrZswrmcwrzMwr/8xVAMxVM8xVZsxVmcxVzMxV/8yAAMyA
M8yAZsyAmcyAzMyA/8yqAMyqM8yqZsyqmcyqzMyq/8zVAMzVM8zVZszVmczVzMzV
/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8Amf8AzP8A//8rAP8rM/8rZv8r
mf8rzP8r//9VAP9VM/9VZv9Vmf9VzP9V//+AAP+AM/+AZv+Amf+AzP+A//+qAP+q
M/+qZv+qmf+qzP+q///VAP/VM//VZv/Vmf/VzP/V////AP//M///Zv//mf//zP//
/wAAAAAAAAAAAAAAACH5BAEAAPwALAAAAAAQABAAAAh7APcJHEiwoMGDCAXWU8aQ
mDKCDRlmYsgQorKF0JQR26exYSaBkz46pHgRWr2BysQIZLhwJUeN+9A85Diyo0Zo
+8TcQJmxIs6VAD4qdLhv4UmBYmIUJFlxHzEAGwlunDkwxs6lTqPuywRgJlVlPwfq
LBq26MOeMRNSTRgQADs=
'''
img = tk.PhotoImage(data=data)
label = tk.Label(image=img)
label.pack()
root.mainloop()
그렇다면,
↑와 같은 코드 임베디드 이미지를 표시할 수 있습니다.
제목 옆의 아이콘을 코드에 삽입하는 방법
여기까지 오면, 조금입니다. 지금 묻은 이미지를 제목 옆에 표시해 주면 됩니다. 여기에서
title.pyroot.tk.call('wm', 'iconphoto', root._w, tk.PhotoImage(data=data))
를 사용하여 아이콘을 표시합니다.
title.pyimport tkinter as tk
root = tk.Tk()
data = '''R0lGODlhEAAQAPcAAAAAAAAAMwAAZgAAmQAAzAAA/wArAAArMwArZgArmQArzAAr
/wBVAABVMwBVZgBVmQBVzABV/wCAAACAMwCAZgCAmQCA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8TcQJmxIs6VAD4qdLhv4UmBYmIUJFlxHzEAGwlunDkwxs6lTqPuywRgJlVlPwfq
LBq26MOeMRNSTRgQADs=
'''
root.tk.call('wm', 'iconphoto', root._w, tk.PhotoImage(data=data))
root.mainloop()
실행하면,
라는 바람이 됩니다.
이제 pyinstaller로 설치하더라도 icon.ico를 넣을 필요없이 하나의 파일로 시작할 수 있습니다.
Reference
이 문제에 관하여(tkinter 제목 옆의 아이콘을 코드에 포함하는 방법), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/Dr_Thomas/items/f3b2eff79cba10eb42a3
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
certutil -encode a.gif text.txt
-----BEGIN CERTIFICATE-----
R0lGODlhEAAQAPcAAAAAAAAAMwAAZgAAmQAAzAAA/wArAAArMwArZgArmQArzAAr
/wBVAABVMwBVZgBVmQBVzABV/wCAAACAMwCAZgCAmQCAzACA/wCqAACqMwCqZgCq
mQCqzACq/wDVAADVMwDVZgDVmQDVzADV/wD/AAD/MwD/ZgD/mQD/zAD//zMAADMA
MzMAZjMAmTMAzDMA/zMrADMrMzMrZjMrmTMrzDMr/zNVADNVMzNVZjNVmTNVzDNV
/zOAADOAMzOAZjOAmTOAzDOA/zOqADOqMzOqZjOqmTOqzDOq/zPVADPVMzPVZjPV
mTPVzDPV/zP/ADP/MzP/ZjP/mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YrAGYr
M2YrZmYrmWYrzGYr/2ZVAGZVM2ZVZmZVmWZVzGZV/2aAAGaAM2aAZmaAmWaAzGaA
/2aqAGaqM2aqZmaqmWaqzGaq/2bVAGbVM2bVZmbVmWbVzGbV/2b/AGb/M2b/Zmb/
mWb/zGb//5kAAJkAM5kAZpkAmZkAzJkA/5krAJkrM5krZpkrmZkrzJkr/5lVAJlV
M5lVZ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AmWYAzGYA/2YrAGYr
M2YrZmYrmWYrzGYr/2ZVAGZVM2ZVZmZVmWZVzGZV/2aAAGaAM2aAZmaAmWaAzGaA
/2aqAGaqM2aqZmaqmWaqzGaq/2bVAGbVM2bVZmbVmWbVzGbV/2b/AGb/M2b/Zmb/
mWb/zGb//5kAAJkAM5kAZpkAmZkAzJkA/5krAJkrM5krZpkrmZkrzJkr/5lVAJlV
M5lVZplVmZlVzJlV/5mAAJmAM5mAZpmAmZmAzJmA/5mqAJmqM5mqZpmqmZmqzJmq
/5nVAJnVM5nVZpnVmZnVzJnV/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwAM8wAZswA
mcwAzMwA/8wrAMwrM8wrZswrmcwrzMwr/8xVAMxVM8xVZsxVmcxVzMxV/8yAAMyA
M8yAZsyAmcyAzMyA/8yqAMyqM8yqZsyqmcyqzMyq/8zVAMzVM8zVZszVmczVzMzV
/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8Amf8AzP8A//8rAP8rM/8rZv8r
mf8rzP8r//9VAP9VM/9VZv9Vmf9VzP9V//+AAP+AM/+AZv+Amf+AzP+A//+qAP+q
M/+qZv+qmf+qzP+q///VAP/VM//VZv/Vmf/VzP/V////AP//M///Zv//mf//zP//
/wAAAAAAAAAAAAAAACH5BAEAAPwALAAAAAAQABAAAAh7APcJHEiwoMGDCAXWU8aQ
mDKCDRlmYsgQorKF0JQR26exYSaBkz46pHgRWr2BysQIZLhwJUeN+9A85Diyo0Zo
+8TcQJmxIs6VAD4qdLhv4UmBYmIUJFlxHzEAGwlunDkwxs6lTqPuywRgJlVlPwfq
LBq26MOeMRNSTRgQADs=
'''
img = tk.PhotoImage(data=data)
label = tk.Label(image=img)
label.pack()
root.mainloop()
여기까지 오면, 조금입니다. 지금 묻은 이미지를 제목 옆에 표시해 주면 됩니다. 여기에서
title.py
root.tk.call('wm', 'iconphoto', root._w, tk.PhotoImage(data=data))
를 사용하여 아이콘을 표시합니다.
title.py
import tkinter as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AAAAAAAAAAACH5BAEAAPwALAAAAAAQABAAAAh7APcJHEiwoMGDCAXWU8aQ
mDKCDRlmYsgQorKF0JQR26exYSaBkz46pHgRWr2BysQIZLhwJUeN+9A85Diyo0Zo
+8TcQJmxIs6VAD4qdLhv4UmBYmIUJFlxHzEAGwlunDkwxs6lTqPuywRgJlVlPwfq
LBq26MOeMRNSTRgQADs=
'''
root.tk.call('wm', 'iconphoto', root._w, tk.PhotoImage(data=data))
root.mainloop()
실행하면,
라는 바람이 됩니다.
이제 pyinstaller로 설치하더라도 icon.ico를 넣을 필요없이 하나의 파일로 시작할 수 있습니다.
Reference
이 문제에 관하여(tkinter 제목 옆의 아이콘을 코드에 포함하는 방법), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/Dr_Thomas/items/f3b2eff79cba10eb42a3텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)