Python tkinter如何在任务栏处闪动一下窗口?

我正在编写一个聊天程序,用的是tkinter,希望能够在收到消息的时候,使任务栏处的窗口闪动一下(就像微信和qq收到消息后一样)。如何做到闪动一下窗口?

可以使用winapi(user32)的FalshWindow功能。
下面是示例:

from tkinter import *
from tkinter import ttk
from ctypes import *
u32=windll.user32

def test():
    u32.FlashWindow(u32.GetParent(r.winfo_id()),True)
    print('yes')


r=Tk()
r.title('test tkinter')

r.after(3000,test)

r.mainloop()

当窗口没有焦点时,会触发FlashWindow。如果想要定义更多内容,可以使用FalshWindowEx
关于后者,见https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-flashwindowex