Align tabs from right to left using ttk.Notebook widget

前端 未结 2 1008
闹比i
闹比i 2021-01-04 15:28

I want to align tabs (panes) inside a ttk.Notebook widget from right to left (the default is from left to right). How might this be done?

Below is my current code:

2条回答
  •  渐次进展
    2021-01-04 16:04

    There is actually a style option for this - tabposition.

    import tkinter as tk
    from tkinter import ttk
    
    root = tk.Tk()
    root.minsize(300, 300)
    root.geometry("1000x700")
    
    s = ttk.Style()
    s.configure('TNotebook', tabposition='ne') #'ne' as in compass direction
    
    box = ttk.Notebook(root, width=1000, height=650)
    
    tab1 = tk.Frame(root)
    tab2 = tk.Frame(root)
    tab3 = tk.Frame(root)
    
    box.add(tab1, text="tab1")
    box.add(tab2, text="tab2")
    box.add(tab3, text="tab3")
    
    box.pack(side=tk.TOP)
    
    root.mainloop()
    

提交回复
热议问题