Python Forum
Tkinter - How can I remove the background borders from ttk.Button?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tkinter - How can I remove the background borders from ttk.Button?
by default, the buttons from ttk module, have a one pixel border. how can I delete this border? below an example code:

from tkinter import *
from tkinter import ttk

root = Tk()

style.configure("TButton", padding=0, background="#ffffff") # I colored the background border white to make it visible in the window.. but, I don't want it, I want to delete the border!

MyButton = ttk.Button(root, text="I have a white border.. how can I delet it?"), y=16)

I don't want to change the border color in order to hide it in the window,I want to delete it.

[Image: PQ9EE.png]
I would try borderwidth=0 in the call to create the button or the Style.
(Oct-18-2020, 07:17 AM)Gribouillis Wrote: I would try borderwidth=0 in the call to create the button or the Style.
I had already tried but it doesn't work.. if I add the "borderwidth=0" option in the style object, it just doesn't work, but if I add this option in MyButton object, the script doesn't start because of the below error message:

_tkinter.TclError: unknown option "-borderwidth"

how can I delete this annoying border? I really can't find a solution. I'm becoming crazy..
For me it works in Linux if I use
style.configure("TButton", padding=0, background="#ffffff", borderwidth=0)

Attached Files

mm.. I don't use Linux now, but from your screenshot, it seems that the button has not the native border anymore. now it looks like a label, but it's not what I want to do, I want to delete the "extra" border, not the native border of the TTK button.

however, I want to delete the extra border because I must allign perfectly the button widgets with the other kind of widgets in my Frame (they don't have the extra border) using the grid method. now, to solve this issue, I created an 1px column to take the extra border.. but it's a workaround, it's not a real solution!

Possibly Related Threads…
Thread Author Replies Views Last Post
  Creating a function interrupt button tkinter AnotherSam 2 488 Oct-07-2021, 02:56 PM
Last Post: AnotherSam
  [Tkinter] Have tkinter button toggle on and off a continuously running function AnotherSam 5 523 Oct-01-2021, 05:00 PM
Last Post: Yoriz
  tkinter showing image in button rwahdan 3 1,385 Jun-16-2021, 06:08 AM
Last Post: Yoriz
  tkinter button image Nick_tkinter 4 1,522 Mar-04-2021, 11:33 PM
Last Post: deanhystad
  tkinter python button position problem Nick_tkinter 3 1,256 Jan-31-2021, 05:15 AM
Last Post: deanhystad
  TKinter restarting the mainloop when button pressed zazas321 7 4,255 Jan-26-2021, 06:38 AM
Last Post: zazas321
  tkinter touchscreen scrolling - button press makes unwanted scrolling nanok66 1 1,369 Dec-28-2020, 10:00 PM
Last Post: nanok66
Question [Tkinter] Can I set background color for each item in tkinter Combobox? water 1 2,057 Dec-10-2020, 07:48 PM
Last Post: Larz60+
Photo Tkinter TEXT background image _ShevaKadu 5 3,757 Nov-02-2020, 10:34 AM
Last Post: joe_momma
  tkinter | Button color text on Click Maryan 2 1,394 Oct-09-2020, 08:56 PM
Last Post: Maryan

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020