1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Tkinter ttk.button background is leaking color outside the button border

Discussão em 'Python' iniciado por Stack, Novembro 23, 2025.

  1. Stack

    Stack Membro Participativo

    [​IMG]

    Button is created like:

    style.configure('Dark.TButton', background=button_base, foreground=colors['text'], borderwidth=1,
    bordercolor=edge, lightcolor=edge, darkcolor=edge, padding=(10, 4))
    style.map('Dark.TButton',
    background=[('pressed', pressed_bg or hover_bg or button_base),
    ('active', hover_bg or button_base),
    ('!disabled', 'red')],
    foreground=[('active', colors['text']), ('pressed', colors['text'])],
    bordercolor=[('pressed', edge), ('active', edge)],
    lightcolor=[('pressed', edge), ('active', edge)],
    darkcolor=[('pressed', edge), ('active', edge)])

    style.layout('Dark.TButton', [
    ('Button.border', {'sticky': 'nswe', 'children': [
    ('Button.padding', {'sticky': 'nswe', 'children': [
    ('Button.label', {'sticky': 'nswe'})
    ]})
    ] })
    ])


    Colored red so the effect is more obvious, i have tried setting borderwidth higher but that just pushes the border further out while keeping its thickness the same

    With Tk.button I lose the beveled border but at least it doesn't leak outside:

    [​IMG]

    Continue reading...

Compartilhe esta Página