简体   繁体   English

将笔记本选项卡与右侧的 Tkinter 树视图对齐

[英]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"制表位=“ne”

n >first to the north, the top. n >首先向北,顶部。 e >and then to the east, the right. e > 然后向东,向右。

if you change it to tabposition="en"如果您将其更改为 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. Hasta la próxima。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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