簡體   English   中英

將筆記本選項卡與右側的 Tkinter 樹視圖對齊

[英]Align notebook tabs to the right Tkinter treeview

我有一個將筆記本選項卡放在窗口右側的代碼。 我有兩個選項卡,這些選項卡的名稱長度不同。 有沒有辦法在右側對齊所有選項卡,以便我在第一個選項卡之前沒有空白空間?

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()

制表位=“ne”

n >首先向北,頂部。 e > 然后向東,向右。

如果您將其更改為 tabposition="en"

它將首先將選項卡放在右側,然后放在頂部。 您將獲得標簽的另一個位置。 這與上面的例子不同。

有一個灰色的一天。 洲。 Hasta la próxima。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM