简体   繁体   English

如何在不将其从任务栏中删除的情况下更改 tkinter window header 的颜色?

[英]How to change the colour of tkinter window header without removing it from the taskbar?

I'm creating a GUI in tkinter and I'm trying to customize the window header so I can change the colour.我正在 tkinter 中创建一个 GUI,我正在尝试自定义 window header 以便我可以更改颜色。

I've used:我用过:

root.overrideredirect(True)

to get rid of the header, then rebuilt the function of moving the tab with:摆脱 header,然后重建移动标签的 function:

def move_window(event):
    x, y = root.winfo_pointerxy()
    root.geometry(f"+{x-650}+{y}")

title_bar = tk.Frame(root, bg=pallete["pallete1"], bd=0,height=22)
title_bar.config(highlightthickness=2, highlightcolor= pallete["pallete3"])
title_bar.pack(fill="x")
title_bar.bind('<B1-Motion>', move_window)

Only this is, that when I overrideredirect to get rid of the window header, the program disappears in the taskbar, so you can't find it.只有这样,当我overrideredirect重定向以摆脱 window header 时,程序在任务栏中消失了,所以你找不到它。

I'm just wondering if there is a way to get around this or to change the window header without having to remove it and rebuild a new one.我只是想知道是否有办法解决这个问题或更改 window header 而无需删除它并重建一个新的。

   
 def minsize():                    # minsize func() for your button
        root.overrideredirect(0)   # minsize window and iconify
        root.iconify()

def showwindow(event):
        root.overrideredirect(1)
        root.iconify()

bind this to your heading bar with map使用map将此绑定到您的标题栏

your_widdgget.bind("<Map>", lambda event: showindow(event)) # in this case i don't know why lambda but it still works for me

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM