0

I'm creating a GUI in tkinter and I'm trying to customize the window header so I can change the colour.

I've used:

root.overrideredirect(True)

to get rid of the header, then rebuilt the function of moving the tab with:

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.

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.

martineau
  • 119,623
  • 25
  • 170
  • 301
sebtheoo
  • 125
  • 10
  • Does this answer your question? [Can I change the title bar in Tkinter?](https://stackoverflow.com/questions/23836000/can-i-change-the-title-bar-in-tkinter) – nbk May 26 '21 at 16:57
  • @nbk no, that's where I originally looked and used some of their code but still doesn't work – sebtheoo May 26 '21 at 16:58
  • so you look for dragging win when you overrideriderct? or you need that icon if you minsize your app? for override here ist the perfect answer from TheLizzard = https://stackoverflow.com/questions/66968676/how-to-get-a-better-window-postion-if-i-click-on-an-overrideredirectted-window. It doesn't come clear to me what exactly you mean. also there is an option `iconify` you can use it with override – bangKok May 26 '21 at 17:00
  • the accepted answer changes the color of the title bar to what your enter i tried it with green instead of white, , so can you explain what doesn't woirk with that answer? – nbk May 26 '21 at 17:13
  • @nbk that accepted answer lets you move and close the screen, I'm looking to be able to minimize then open it up again from the taskbar. root.overrideredirect(True) doesn't show the program in the taskbar. – sebtheoo May 26 '21 at 17:16
  • @JoeMo thank you, this seems to help. I'm able to minimize by setting root.overrideredirect to False, but when I open the program, the window header now appears back. – sebtheoo May 26 '21 at 17:17

1 Answers1

1
   
 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

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