简体   繁体   中英

Align notebook tabs to the right Tkinter treeview

I have a code that places the notebook tabs on the right side of the window. I have two tabs, and names of those tabs are different length. Is there a way to align all tabs on the right side, so that I do not have the empty space before first tab?

import tkinter as tk
from tkinter import ttk

root = tk.Tk()

style = ttk.Style(root)
style.configure('lefttab.TNotebook', tabposition='wn')

notebook = ttk.Notebook(root, style='lefttab.TNotebook')

f1 = tk.Frame(notebook, bg='red', width=200, height=200)
f2 = tk.Frame(notebook, bg='blue', width=200, height=200)

notebook.add(f1, text='Shorter Name ')
notebook.add(f2, text='Much Longer Name')

notebook.grid(row=0, column=0, sticky="nw")

root.mainloop()

tabposition="ne"

n >first to the north, the top. e >and then to the east, the right.

if you change it to tabposition="en"

It will first put the tabs to the right, and then to the top. You will get another position of the tabs. It's different from the above example.

Have a greay day. Chau. Hasta la próxima.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM