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?
#1
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()
root.geometry("400x300")

style=ttk.Style()
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?")
MyButton.place(x=16, y=16)

root.mainloop()
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]
Reply
#2
I would try borderwidth=0 in the call to create the button or the Style.
Reply
#3
(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..
Reply
#4
For me it works in Linux if I use
style.configure("TButton", padding=0, background="#ffffff", borderwidth=0)

Attached Files

Thumbnail(s)
   
Reply
#5
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!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  tkinter | Button color text on Click Maryan 2 138 Oct-09-2020, 08:56 PM
Last Post: Maryan
  [Tkinter] button command tkinter Heyjoe 6 1,248 Jul-30-2020, 07:06 PM
Last Post: deanhystad
  [tkinter] color change for hovering over button teacher 4 521 Jul-04-2020, 06:33 AM
Last Post: teacher
  tkinter button help Gina92 10 622 May-27-2020, 08:17 AM
Last Post: Gina92
  How to make button text bold in Tkinter? scratchmyhead 2 552 May-16-2020, 02:53 AM
Last Post: scratchmyhead
  [Tkinter] Is it possible to automate button generation in tkinter? FirePepi 3 487 Apr-10-2020, 12:14 PM
Last Post: Riddle
  Tkinter:Unable to bind and unbind function with a button shallanq 2 600 Mar-28-2020, 02:05 AM
Last Post: joe_momma
  Returning a value from a tkinter.button call markr0804 4 2,701 Feb-16-2020, 10:35 AM
Last Post: markr0804
  Problem with Submit button Tkinter Reldaing 2 567 Jan-05-2020, 01:58 AM
Last Post: balenaucigasa
  Restoring Tkinter widget background to original color pythonprogrammer 1 670 Dec-16-2019, 04:59 AM
Last Post: woooee

Forum Jump:

User Panel Messages

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