Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get rid of widget border?

Tags:

python

tkinter

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?

like image 735
Kriattiffer Avatar asked Feb 15 '23 04:02

Kriattiffer


1 Answers

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.

like image 157
Bryan Oakley Avatar answered Feb 24 '23 00:02

Bryan Oakley