【发布时间】:2021-10-17 02:28:54
【问题描述】:
我有一个图像,我想让我的 python 程序 (tkinter GUI) 将其可视化为 Windows 任务栏中的图标,我该怎么做?
【问题讨论】:
标签: python-3.x windows image tkinter icons
我有一个图像,我想让我的 python 程序 (tkinter GUI) 将其可视化为 Windows 任务栏中的图标,我该怎么做?
【问题讨论】:
标签: python-3.x windows image tkinter icons
当文件是.py 时,我认为你不能这样做。它必须是可执行文件。
https://www.geeksforgeeks.org/convert-python-script-to-exe-file/
打开任何终端(如 cmd、WT 或 PS)并与其他 pyinstaller 标志一起添加 --icon="path_to_icon.ico"
例子:
pyinstaller my_program.py --icon="icon.ico"
【讨论】:
icon = tk.PhotoImage(file="icon.png")
root.iconphoto(True, icon)
请注意,这只处理 2 个图标位置中的 1 个,文件的图标需要在 Windows 资源管理器中设置。
【讨论】: