简体   繁体   English

如何使按钮在tkinter GUI上平

[英]how to make buttons FLAT on tkinter GUI

Hello beautiful community. 您好美丽的社区。 I am working on a tkinter GUI on a raspberry. 我正在树莓上的Tkinter GUI上工作。 Well first i started programming my gui on windows and i wanted to make my buttons look flat on screen without any lines on the edges and using relief='flat' worked well, But when i finished my project and i ran my program on my raspberry my buttons had those lines on the edge it seems like relief='flat' doesnt have any effect and i tried to use relief=FLAT and still same problem 好吧,首先,我开始在Windows上对gui进行编程,我想使按钮在屏幕上看起来很平整,边缘没有任何线条,并且使用救济=“ flat”效果很好,但是当我完成项目并在树莓派上运行程序时我的按钮的边缘上有那些线,似乎relief ='flat'没有任何效果,我尝试使用relief = FLAT还是同样的问题

Here you can see a Screenshot of the running program and lines arround my buttons 在这里,您可以看到正在运行的程序的屏幕截图,以及按钮周围的行

我的覆盆子屏幕的屏幕截图

and here's my code 这是我的代码

bouton_break = Button(f2, image=img_break, relief='flat' , command = break_ )  #break
bouton_break.place(bordermode=OUTSIDE, height=134, width=107, x=40 , y=200)
bouton_MM = Button(f2, image=img_MM, relief='flat', command=maint_page)
bouton_MM.place(bordermode=OUTSIDE, height=134, width=107, x=170 , y=200)
boutonlogout = Button(f2, image=img_logout , relief='flat', command = logout_cmd)  #logout
boutonlogout.place(bordermode=OUTSIDE, height=134, width=107, x=300 , y=200)

My guess is that what you're seeing is the focus highlight ring. 我的猜测是您看到的是焦点突出显示环。 This is used to let the user know which button has the keyboard focus. 这用于让用户知道哪个按钮具有键盘焦点。 To turn that off set the highlightthickness to zero: 要将其关闭,请将highlightthickness厚度设置为零:

bouton_break = Button(..., highlightthickness=0)

If you don't want to turn it off, you can still get a more visually clean appearance by making sure the highlightbackground option to the same color as the background so that it effectively disappears when the button doesn't have focus. 如果您不想将其关闭,则可以通过确保highlightbackground选项具有与背景相同的颜色来获得更加视觉上清晰的外观,以便在按钮没有焦点时有效地消失。

Set button border = 0. 设置按钮边框= 0。

bd=0

(extra caharacters to satisfy SO) (满足SO的额外特性)

Try this: 尝试这个:

button_break = Button(f2, image=img_break, relief='flat', highlightthickness=0, bd=0, command=break_)
button_break.place(bordermode=OUTSIDE, height=134, width=107, x=40, y=200)
button_MM = Button(f2, image=img_MM, relief='flat', highlightthickness=0, bd=0, command=maint_page)
button_MM.place(bordermode=OUTSIDE, height=134, width=107, x=170, y=200)
button_logout = Button(f2, image=img_logout, relief='flat', highlightthickness =0, bd=0, command=logout_cmd)
button_logout.place(bordermode=OUTSIDE, height=134, width=107, x=300, y=200)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM