问题描述
我有以下代码:
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()
如您所见,如果您运行它(尤其是在全屏模式下),窗口边缘附近有灰色边框.它看起来像 PanedWindow 小部件的边框(你可以看到它,如果你设置它的 fill=NONE
并展开窗口).注意ts borderwidth设置为0
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?
推荐答案
您看到的是画布周围的高亮环 - 改变颜色以表明画布具有键盘焦点的东西.使用 highlightthickness
属性将其设置为零:
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)
请注意,它也可能是画布边框.您可能还想将 borderwidth
设置为零.
Note that it could also be the canvas border. You might want to set borderwidth
to zero, too.
这篇关于如何摆脱小部件边框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!