Change Icon For Tkinter Messagebox

前端 未结 2 1743
说谎
说谎 2021-01-13 02:15

Is there a way to change the icon of a tkinter message box? Here is my code:

from tkinter import *
import tkinter.messagebox as messagebox

root = Tk()
mess         


        
2条回答
  •  既然无缘
    2021-01-13 02:58

    Yes, there is such an option. Assuming your root Tkinter instance is called root, your import statement is from tkinter import *, and your image file is named 'ico.gif':

    root.tk.call('wm', 'iconphoto', root._w, PhotoImage(file='ico.gif'))
    

    Call this method after creating the root object and before popping the messagebox. The icon will apply to the root object as well as to the messagebox.

提交回复
热议问题