5

I have a program with several frames. Everything works well however I cannot figure out why the border around one of the frames exist.

I have tried a few things.

Here is how my frame is created:

kwListFrame = Frame(root)
kwListFrame.grid(row = 1, column = 0, rowspan = 1, columnspan = 1, sticky = N+S+E+W)
kwListFrame.columnconfigure(0, weight=1)
kwBGimage = Label(kwListFrame, image= baseBGimage)
kwBGimage.image = baseBGimage
kwBGimage.place(x = 0, y = 0)
kwBGimage.config(image = baseBGimage)

I have tried to change:

kwListFrame = Frame(root)

To:

kwListFrame = Frame(root, highlightthickness=0)
#or
kwListFrame = Frame(root, padx=0, pady=0)
#or
kwListFrame = Frame(root, bd=0)

And after that didnt work I tried:

kwListFrame = Frame(root, highlightbackground= "some color that matches frame")

I even tried to set the relief to flat even thought I know its default value is flat.

As I have found several references to removing the border on canvas, I have not found anything related to Frames directly. So I may be using the highlightthickness and highlightbackground wrong but it did not throw an error so it seams like it should do the trick.

Here is an image of the way the frame displays a thin border at the top.

enter image description here

I am not sure why the problem exist. Is it because I am using an image as the background?

I did not want to post all my code here because it would be to much but if you want to see the full code my program is on Github

martineau
  • 119,623
  • 25
  • 170
  • 301
Mike - SMT
  • 14,784
  • 4
  • 35
  • 79

1 Answers1

15

The first step is to set both the borderwidth and highlightthickness to zero. A frame has two border-like objects: the actual border and a "highlight ring". The latter is for showing that a frame has focus.

Once you do that, the frame will not have a border. If there's still some sort of border-like ring around the widget it is likely due to padding applied to the geometry manager, and what you are seeing is the color from the parent window.

In your specific case, since you are putting a label in the frame you need to turn the border of the label off, too. Most likely you are seeing the border of the label rather than the border of the frame.

I can't be any more specific since you didn't provide a minimal but otherwise fully working example that illustrates the problem.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
  • 1
    I did try `kwListFrame = Frame(root, borderwidth = 0, highlightthickness = 0)` this also didn't work. I did link my github for the full code. There was way to much to post here. I will check to see if I have any padding that would cause this problem. – Mike - SMT May 09 '17 at 21:50
  • 1
    @SierrMountainTech: I've updated my answer. What you are seeing is probably the border of the label. – Bryan Oakley May 09 '17 at 21:54
  • Thank you for that. You are correct it was the `Label Border`. This fixed my problem. Thanks again. – Mike - SMT May 09 '17 at 21:57
  • All it took was `kwBGimage = Label(kwListFrame, image= baseBGimage, borderwidth = 0, highlightthickness = 0)` – Mike - SMT May 09 '17 at 21:58