Problem
My problem is that I want to make a custom title bar for my Tkinter app. I didn't want to use root.overrideredirect(True) because it removes the app from the taskbar. So I decided to use root.attributes('-type', 'splash') but when I run the app i get this error:
_tkinter.TclError: wrong # args: should be "wm attributes window ?-alpha ?double?? ?-transparentcolor ?color?? ?-disabled ?bool?? ?-fullscreen ?bool?? ?-toolwindow ?bool?? ?-topmost ?bool??"
Code
from tkinter import *
from tkinter.ttk import Notebook, Style, Separator
# root of app
root = Tk()
root.geometry("800x600")
root.attributes('-type', 'splash')
# style
style = Style()
# background color of separator
style.configure("Line.TSeparator", background="#2C313A")
# icons
icon = PhotoImage(file="icon.png")
menu_icon = PhotoImage(file="menu.png")
close_icon = PhotoImage(file="close.png")
maximize_icon = PhotoImage(file="maximize.png")
minimize_icon = PhotoImage(file="minimize.png")
restore_icon = PhotoImage(file="restore.png")
# make a frame for the title bar
title_bar = Frame(root, bg='#21252B', bd=0)
title_bar.place(relx=0, rely=0, relwidth=1, height=45)
# Close button for title bar
close_button = Button(title_bar, bg='#21252B', bd=0, image=close_icon, command=root.destroy)
close_button.place(relx=0.95, rely=0.35)
# Maximize button for title bar
max_button = Button(title_bar, bg='#21252B', bd=0, image=maximize_icon, command=root.destroy)
max_button.place(relx=0.9, rely=0.275)
# Restore button for title bar
restore_button = Button(title_bar, bg='#21252B', bd=0, image=restore_icon, command=root.destroy)
# Minimize button for title bar
min_button = Button(title_bar, bg='#21252B', bd=0, image=minimize_icon, command=root.destroy)
min_button.place(relx=0.85, rely=0.275)
# Icon for title bar
title_bar_icon = Label(title_bar, image=icon, bg='#21252B')
title_bar_icon.pack(side=LEFT)
# bottom separator for title bar
title_bar_separator = Separator(root, orient="horizontal", style="Line.TSeparator")
title_bar_separator.place(relx=0, rely=0.075, relwidth=1)
root.mainloop()
Full Error
C:\Users\User\AppData\Local\Programs\Python\Python39\python.exe C:/Users/User/Desktop/PythonProjects/SideDrawer/main.py
Traceback (most recent call last):
File "C:\Users\User\Desktop\PythonProjects\SideDrawer\main.py", line 7, in <module>
root.attributes('type', 'splash')
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 1976, in wm_attributes
return self.tk.call(args)
_tkinter.TclError: wrong # args: should be "wm attributes window ?-alpha ?double?? ?-transparentcolor ?color?? ?-disabled ?bool?? ?-fullscreen ?bool?? ?-toolwindow ?bool?? ?-topmost ?bool??"
Process finished with exit code 1
So How do I fix this