I use ttk.Notebook
to create different tabs. The notebook is placed on the left side.
The labels in the tabs should not be aligned to the right, but to the left.
Can this be configured?
Right-aligned tabs:
Code Snippet:
import tkinter as tk
from ttkthemes import ThemedTk
import tkinter.ttk as ttk
class MyApp(ThemedTk):
def __init__(self, theme="arc"):
ThemedTk.__init__(self, fonts=True, themebg=True)
self.set_theme(theme)
self.style = ttk.Style()
self.style.configure('lefttab.TNotebook', tabposition='wn')
current_theme =self.style.theme_use()
self.style.theme_settings(current_theme, {"TNotebook.Tab": {"configure": {'background':'white', "padding": [10, 8]}}})
self.nb = ttk.Notebook(self, style='lefttab.TNotebook')
self.nb.grid(row=0, column=0, sticky='w')
self.page0 = ttk.Frame(self.nb, width=500, height=300)
self.page1 = ttk.Frame(self.nb, width=500, height=300)
self.page2 = ttk.Frame(self.nb, width=500, height=300)
self.style.configure("TFrame", background='white')
self.nb.add(self.page0, text='Allgemein', sticky="nsew")
self.nb.add(self.page1, text='Wand leicht', sticky="nsew")
self.nb.add(self.page2, text='Wand schwer', sticky="nsew")
self.ok = ttk.Button(self.page1)
self.ok["text"] = "Button"
self.ok["command"] = self.handler
self.ok.grid(row=0, column=0)
def handler(self):
print("Button clicked")
if __name__ == "__main__":
app = MyApp()
app.geometry("500x300")
app.mainloop()