【问题标题】:Display a png (or ico) as icon in the windows taskbar在 Windows 任务栏中将 png(或 ico)显示为图标
【发布时间】:2021-10-17 02:28:54
【问题描述】:

我有一个图像,我想让我的 python 程序 (tkinter GUI) 将其可视化为 Windows 任务栏中的图标,我该怎么做?

【问题讨论】:

    标签: python-3.x windows image tkinter icons


    【解决方案1】:

    当文件是.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"
    

    【讨论】:

      【解决方案2】:
      icon = tk.PhotoImage(file="icon.png")
      root.iconphoto(True, icon)
      

      请注意,这只处理 2 个图标位置中的 1 个,文件的图标需要在 Windows 资源管理器中设置。

      【讨论】:

      • 是的,我已经用It做窗口的图标了,这不是问题,是窗口任务栏我无法通过代码设置。
      猜你喜欢
      • 2017-11-01
      • 2012-12-03
      • 1970-01-01
      • 2011-09-15
      • 2018-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-02
      相关资源
      最近更新 更多