[英]Align tabs from right to left using ttk.Notebook widget
I want to align tabs (panes) inside a ttk.Notebook
widget from right to left (the default is from left to right).我想从右到左对齐
ttk.Notebook
小部件内的选项卡(窗格)(默认是从左到右)。 How might this be done?如何做到这一点?
Below is my current code:以下是我目前的代码:
import Tkinter as tk
import ttk
root = tk.Tk()
root.minsize(300, 300)
root.geometry("1000x700")
box = ttk.Notebook(root, width=1000, height=650)
tab1 = tk.Frame(root)
tab2 = tk.Frame(root)
tab3 = tk.Frame(root)
box.add(tab1, text="tab1")
box.add(tab2, text="tab2")
box.add(tab3, text="tab3")
box.pack(side=tk.TOP)
root.mainloop()
There is actually a style option for this - tabposition . 实际上有一个样式选项 - tabposition 。
import tkinter as tk
from tkinter import ttk
root = tk.Tk()
root.minsize(300, 300)
root.geometry("1000x700")
s = ttk.Style()
s.configure('TNotebook', tabposition='ne') #'ne' as in compass direction
box = ttk.Notebook(root, width=1000, height=650)
tab1 = tk.Frame(root)
tab2 = tk.Frame(root)
tab3 = tk.Frame(root)
box.add(tab1, text="tab1")
box.add(tab2, text="tab2")
box.add(tab3, text="tab3")
box.pack(side=tk.TOP)
root.mainloop()
In Oblivion's line:在 Oblivion 中:
s.configure('TNotebook', tabposition='ne')
the 'ne' bit can be: 'ne' 位可以是:
nw => above (north) and to the left (west)
ne => above and to the right (east)
en => to the right (east), at the top
es => to the right (east), at the bottom
se => below (south) and to the right (east)
sw => below (south) and to the left (west)
ws => to the left (west) and to the bottom (south)
wn => to the left (west) and at top
'nw' is, I guess, the more common one, but an application may require it otherwise. 'nw' 是,我猜,更常见的,但应用程序可能需要它否则。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.