Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
413 views
in Technique[技术] by (71.8m points)

python - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...