pythonpython-3.xtkintertabcontrol

Tkinter: remove the borders of all Tabcontrol and its tabs


I would like to remove the Tabcontrol border. Let me explain better: i would like to give the optical illusion that the topbar and the left tabcontrol were a single element. If you test my executable code, you will understand. enter image description here

But, as you can see, between the Tabcontrol and the Topbar there is a gray line, which is the edge of the tabcontrol. So I would like to remove the border of the Tabcontrol to avoid seeing that gray line between the tabcontrol and the topbar.

Same thing with the tab border of the tabcontrol: when I select a tab, its borders are grey/white. I would like to change remove them but changing colors.

I try borderwidth=0, but don't work.

I would like to get something like this:

enter image description here

from tkinter import *
from tkinter import ttk
import tkinter as tk

window = tk.Tk()

style = ttk.Style(window)
style.theme_use('clam')
window.attributes('-zoomed', True)

#Topbar
topbar = tk.Frame(window, bg='#d20808', height=70, highlightthickness=1, highlightbackground="#a39c8f")
topbar.pack(fill='x')


#Style Tabcontrol
style.configure('lefttab.TNotebook', tabposition=tk.W + tk.N, tabplacement=tk.N + tk.EW,  background='#d20808',
                                     borderwidth=0, highlightbackground='#d20808', highlightthickness =5)

style.configure('lefttab.TNotebook.Tab', background='#d20808', width=21, focuscolor='#e10a0a', foreground='white',
                                         borderwidth=0, highlightbackground='#d20808', highlightthickness = 5)

style.map('lefttab.TNotebook.Tab', background=[('selected', '#960000')])

tabControl = ttk.Notebook(window, style='lefttab.TNotebook', width=700, height=320)

#Tabcontrol  
a = ttk.Notebook(tabControl)
b = ttk.Notebook(tabControl)
c = ttk.Notebook(tabControl)

tabControl.add(a, text ='A')
tabControl.add(b, text ='B')
tabControl.add(c, text ='C')
tabControl.place(x=1, y=70)

Solution

  • I experimented with various settings, such as borderwidth = 0 and highlightthickness = 0, in an attempt to eliminate the border lines, but none of them proved successful.

    Ultimately, I found a solution by switching the theme from clam to classic and adjusting the highlightthickness of the topbar from 1 to 0. This successfully removed the border lines.

    from tkinter import ttk
    import tkinter as tk
    
    window = tk.Tk()
    
    style = ttk.Style(window)
    style.theme_use('classic')
    window.attributes('-fullscreen', True)
    
    #Topbar
    topbar = tk.Frame(window, bg='#d20808', height=70, highlightthickness=0, highlightbackground="#a39c8f")
    topbar.pack(fill='x')
    
    
    #Style Tabcontrol
    style.configure('lefttab.TNotebook', tabposition=tk.W + tk.N, tabplacement=tk.N + tk.EW,  background='#d20808',
                                         borderwidth=0, highlightbackground='#d20808', highlightthickness =0)
    
    style.configure('lefttab.TNotebook.Tab', background='#d20808', width=15, focuscolor='#e10a0a', foreground='white',
                                             borderwidth=0, highlightbackground='#d20808', highlightthickness = 0)
    
    style.map('lefttab.TNotebook.Tab', background=[('selected', '#960000')])
    
    tabControl = ttk.Notebook(window, style='lefttab.TNotebook', width=700, height=320)
    
    #Tabcontrol
    a = ttk.Notebook(tabControl)
    b = ttk.Notebook(tabControl)
    c = ttk.Notebook(tabControl)
    
    tabControl.add(a, text ='A')
    tabControl.add(b, text ='B')
    tabControl.add(c, text ='C')
    tabControl.place(x=0, y=70)
    
    window.mainloop()