Kyle54
Kyle54

Reputation: 133

Setting ttk Notebook tabs in the center [Python]

I want to make my own style in a python / tkinter application using ttk Notebooks. I like the style of the aqua setting shown below.

import tkinter as tk
from tkinter import ttk

root = tk.Tk()
s = ttk.Style(root)
s.theme_use('aqua')

notebook = ttk.Notebook(root)
frame1 = ttk.Frame(root, width=400, height=400)
frame2 = ttk.Frame(root)
notebook.add(frame1, text="Frame1")
notebook.add(frame2, text="Frame2")
notebook.pack()

root.geometry("400x400")
root.mainloop()

aqua theme

But aqua will not let me change the background color of some widgets so I want to use the default style. Is there a way to configure the TNotebook.Tab using the default style to get the tabs in the middle? Something like

s.configure('TNotebook.Tab', tabposition='center')

but I have not found anything that works.

Upvotes: 3

Views: 1931

Answers (1)

jizhihaoSAMA
jizhihaoSAMA

Reputation: 12672

I couldn't use theme aqua on Windows, but use default theme and

s.configure("TNotebook", tabposition='n')

could make the tab in the center.

enter image description here

Upvotes: 3

Related Questions