小编And*_*one的帖子

Tkinter ttk 查看自定义主题设置

使用后ttk.Style().theme_create('name', settings={})可以看到该主题的设置吗?

我问的原因是,当我创建一个新主题并将其添加ttk.Notebook(root)到我的代码中时,选项卡有圆角,这是我不想要的。

这是一个例子:

import tkinter as tk
import tkinter.ttk as ttk


root = tk.Tk()
root.title("Tab Example")
root.geometry('270x270')

background = '#ffffff'
background_dark = '#f2f2f2'

style = ttk.Style()
style.theme_create('white', settings={
    'TLabel': {'configure': {'background': background}},
    'TFrame': {'configure': {'background': background}},
    'TNotebook': {
        'configure': {'background': background_dark, 'tabmargins': [0, 7, 2, 0], 'padding': [7, 2]}},
    'TNotebook.Tab': {
        'configure': {'background': background_dark, 'padding': [7, 2], 'focuscolor': 'clear'},
        'map': {'background': [('selected', background)]}}})

style.theme_use('white')

tab = ttk.Notebook(root)

tab1 = ttk.Frame(tab)
tab2 = ttk.Frame(tab)

tab.add(tab1, text='Tab …
Run Code Online (Sandbox Code Playgroud)

python tkinter ttk

6
推荐指数
1
解决办法
3379
查看次数

标签 统计

python ×1

tkinter ×1

ttk ×1