简体   繁体   English

如何去除TTK Notebook的边框?

[英]How to remove border of TTK Notebook?

Problem问题

My problem is that I need to remove the border for the ttk notebook.我的问题是我需要删除 ttk 笔记本的边框。 I am using ttk as a way of using multiple screens and I have removed the tabs from the notebook by doing: style.layout('TNotebook.Tab', []) but when I did that there is this ugly white border around the notebook this is what it looks like:我正在使用 ttk 作为使用多个屏幕的一种方式,并且我已经通过执行以下操作从笔记本中删除了标签: style.layout('TNotebook.Tab', [])但是当我这样做时,笔记本周围有这个丑陋的白色边框这是它的样子:

在此处输入图像描述

I am new to ttk so I do not know much about styling in the ttk module So how can I remove the ugly white border of the notebook我是 ttk 的新手,所以我对 ttk 模块中的样式了解不多所以我怎样才能删除笔记本丑陋的白色边框

I had a similar situation and wanted to remove the border surrounding Tkinter Notebook.我有类似的情况,想去掉 Tkinter Notebook 周围的边框。 Based on the suggestion from the comment @acw1668 , I was able to remove the border.根据评论@acw1668的建议,我能够删除边框。 I post this answer incase it would help someone with similar problem.我发布这个答案以防它会帮助有类似问题的人。

from tkinter import *
from tkinter import ttk

root = Tk()
root.geometry("400x300")

style=ttk.Style()
style.layout("TNotebook", [])
style.configure("TNotebook", highlightbackground="#848a98",tabmargins=0)# borderwidth = 0, highlightthickness = 0)

MainNotebook = ttk.Notebook(root, style="TNotebook")
MainNotebook.place(x=16, y=16)

Frame1=Frame(MainNotebook, background="#ffffff", width=200, height=150)
Frame1.pack()     
Frame2=Frame(MainNotebook, background="#ffffff", width=200, height=150)
Frame2.pack()

MainNotebook.add(Frame1, text="Tab1")
MainNotebook.add(Frame2, text="Tab2")

root.mainloop()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM