【问题标题】:tkinter set window icon python3tkinter 设置窗口图标 python3
【发布时间】:2022-10-23 20:53:09
【问题描述】:

如果您需要,我想在这里设置图标是我的代码


import tkinter as tk
from tkinter import *

screen = tk.Tk()
screen.title("Python Game")
screen.mainloop()

【问题讨论】:

  • 这回答了你的问题了吗? How to replace the icon in a Tkinter app?
  • 除此之外,如果你想在 python 中创建视频游戏,请使用 pygame 而不是 tkinter。
  • @IbrahimSharaf 这可能是真的,但 it could be useful 可以与 tkinter 一起使用。
  • 请在发布问题之前检查重复或相关问题,额外重复添加额外问题并从主页中删除更重要的未回答问题。

标签: python python-3.x tkinter


【解决方案1】:

screen.iconbitmap('example.ico') 文件应该是 .ico 文件

screen.iconphoto(False, tk.PhotoImage(file='example.png')) 文件应为.png 文件,False 表示仅在当前窗口中使用的图标,如果是True,该图标也会出现在Toplevel 窗口中。

【讨论】: