Kriattiffer
Kriattiffer

Reputation: 647

How to get rid of widget border?

I have the following code:

from Tkinter import *
def gui():
    root = Tk()
    root.configure(background = 'red')

    rightPanel = PanedWindow(borderwidth=0, bg='black')
    rightPanel.pack(side = 'right', fill=BOTH, expand=1)

    canvas1 = Canvas(rightPanel, bg='black')

    rightlabel = Label(canvas1, bg= 'grey')
    rightlabel.place(relx=0.5, rely=0.5, anchor=CENTER)

    canvas1.pack(fill=BOTH, expand=1)
    root.wm_attributes('-topmost', 1)
    mainloop()

if __name__ =='__main__':
    gui()

As you can see if you run it (especially in fullscreen mode), there is grey border near window edge. It looks like border of PanedWindow widget (you can see it, if you set its fill=NONE and expand window). Note that ts borderwidth is set to 0

How can I get rid of it or set it to some color?

Upvotes: 4

Views: 531

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 385890

What you are seeing is the highlight ring around the canvas -- something that changes color to show that the canvas has keyboard focus. Set it to zero with the highlightthickness attribute:

canvas1 = Canvas(rightPanel, bg='black', highlightthickness=0)

Note that it could also be the canvas border. You might want to set borderwidth to zero, too.

Upvotes: 8

Related Questions