我有一個影像,我想讓我的 python 程式(tkinter GUI)將它可視化為 Windows 任務欄中的一個圖示,我該怎么做?
uj5u.com熱心網友回復:
icon = tk.PhotoImage(file="icon.png")
root.iconphoto(True, icon)
請注意,這僅處理 2 個圖示位置中的 1 個,檔案的圖示需要在 Windows 資源管理器中設定。
uj5u.com熱心網友回復:
我認為當檔案是.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"
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/322251.html
