【问题标题】:Align notebook tabs to the right Tkinter treeview将笔记本选项卡与右侧的 Tkinter 树视图对齐
【发布时间】: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()

【问题讨论】:

    标签: python tkinter


    【解决方案1】:

    tabposition="ne"

    n >首先向北,顶部。 e >然后向东,向右。

    如果你把它改成 tabposition="en"

    它将首先将选项卡放在右侧,然后放在顶部。您将获得标签的另一个位置。和上面的例子不一样。

    祝你今天愉快。 洲。 Hasta la próxima。

    【讨论】:

      猜你喜欢
      • 2018-04-05
      • 1970-01-01
      • 2020-10-17
      • 1970-01-01
      • 1970-01-01
      • 2016-07-11
      • 2014-08-21
      • 2011-01-25
      • 2020-02-21
      相关资源
      最近更新 更多