如何隐藏 ttk Notebook 小部件中的选项卡栏?我不想隐藏属于选项卡的框架。我只想将标签栏从视线中删除,即使它不在屏幕顶部(出于多个目的)。
无论如何,全屏模式会很好。
来自 tkinter.ttk.Style 的帮助:
layout(self, style, layoutspec=None)
定义给定样式的小部件布局。如果layoutspec
被省略,返回给定样式的布局规范。
layoutspec
预计是一个列表或一个与以下对象不同的对象None
评估为False
如果你想“关闭”这种风格。
尝试这个:
import tkinter as tk
from tkinter import ttk
root = tk.Tk()
style = ttk.Style()
style.layout('TNotebook.Tab', []) # turn off tabs
note = ttk.Notebook(root)
f1 = ttk.Frame(note)
txt = tk.Text(f1, width=40, height=10)
txt.insert('end', 'Page 0 : a text widget')
txt.pack(expand=1, fill='both')
note.add(f1)
f2 = ttk.Frame(note)
lbl = tk.Label(f2, text='Page 1 : a label')
lbl.pack(expand=1, fill='both')
note.add(f2)
note.pack(expand=1, fill='both', padx=5, pady=5)
def do_something():
note.select(1)
root.after(3000, do_something)
root.mainloop()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)