1

I am experiencing issues with a Python 3 tkinter program I'm working on.

I am running macOS Sierra.

When running the app, every widget has a grey border around it.

Is there any way to remove this?

Screenshot of the border:

A screenshot showing 3 widgets, each with a border

Here's the code:

# Item list
itemlist=Treeview(root)
itemlist.heading("#0", text="Item Name")
itemlist["columns"]=("1")
itemlist.column("1",width=50)
itemlist.heading("1",text="Item ID")
itemlist.bind("<Double-1>", select)
itemlist.grid(row=2,column=1,padx=10,pady=10)

# Nametag
Label(root,text="Name:").grid(row=3,column=0)

# 'Save' Button
saveButton=Button(text="Save")
saveButton.bind("<Button-1>",savebind)
saveButton.grid(row=1,column=0)

# 'Add New' button
newItemButton=Button(text="New Event")
newItemButton.bind("<Button-1>",newItem)
newItemButton.grid(row=0,column=1)

# Name entry text field
itemNameEntry=Entry(root,width=25)
itemNameEntry.grid(row=3,column=1)

# Submit Button
submitButton=Button(root,width=25,text="Submit")
submitButton.grid(row=4,column=1)
submitButton.bind("<Button-1>",submit)

# Begin loading
load()

# Start GUI
root.mainloop()

3 Answers3

1

Configure your widgets to use highlightbackground = 'white' (or whatever your background colour is) and set your highlightthickness=0

This should remove the grey outline.

EG

itemNameEntry=Entry(root,width=25, highlightbackground='white')
itemNameEntry.config(highlightthickness=0)
Luke.py
  • 965
  • 8
  • 17
  • I get `_tkinter.TclError: unknown option "-highlightbackground"` and `_tkinter.TclError: unknown option "-highlightthickness"` when running. –  Feb 27 '17 at 11:32
  • Unfortunately not :( –  Feb 27 '17 at 11:47
  • looks like its a mac issue : http://stackoverflow.com/questions/27084321/tkinter-leaving-borders-around-widgets – Luke.py Feb 27 '17 at 11:53
  • I think they're separate, the colour looks different. –  Feb 27 '17 at 11:57
  • you are comparing 2 different type of widgets there though? – Luke.py Feb 27 '17 at 12:01
  • Yes - but the colour is the same on all widgets in the program, including a button. –  Feb 27 '17 at 12:02
0

You can use widget.config(highlightthickness=0) or pass this parameter in widget constructor.

gcx11
  • 128
  • 4
0

If you are importing tkinter.ttk you need to import that first, then import tkinter.

from tkinter.ttk import *
from tkinter import *
Expliked
  • 101
  • 10