如何在tkinter ttk.Notebook小部件中隐藏整个选项卡栏? [英] How do I hide the entire tab bar in a tkinter ttk.Notebook widget?

查看:148
本文介绍了如何在tkinter ttk.Notebook小部件中隐藏整个选项卡栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在ttk笔记本小部件中隐藏选项卡栏?我不想隐藏属于选项卡的框架.我只是想将标签栏从视线中移开,即使它不在屏幕顶部(出于多个目的).

How do I hide the tab bar in a ttk Notebook widget? I don't want to hide the frame that belongs to the tab. I just want to remove the tab bar from sight, even where it's not at the top of the screen (for more than one purpose).

无论如何,这对于全屏模式会很好.

Anyway, it would be nice for fullscreen mode.

推荐答案

来自tkinter.ttk.Style的帮助:

from the help on tkinter.ttk.Style:

layout(自身,样式,layoutspec = None)

layout(self, style, layoutspec=None)

定义给定样式的小部件布局.如果layoutspec是
省略,返回给定样式的布局规范.

Define the widget layout for given style. If layoutspec is
omitted, return the layout specification for given style.

layoutspec应该是与
不同的列表或对象如果您要关闭"该样式,则没有一个结果为False.

layoutspec is expected to be a list or an object different than
None that evaluates to False if you want to "turn off" that style.

尝试一下:

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

这篇关于如何在tkinter ttk.Notebook小部件中隐藏整个选项卡栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆