【发布时间】:2018-12-13 03:59:24
【问题描述】:
我有一个将笔记本标签放在窗口右侧的代码。我有两个选项卡,这些选项卡的名称长度不同。有没有办法对齐右侧的所有选项卡,以便我在第一个选项卡之前没有空白?
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()
【问题讨论】: