简体   繁体   中英

how to make buttons FLAT on tkinter GUI

Hello beautiful community. I am working on a tkinter GUI on a raspberry. 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

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:

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.

Set button border = 0.

bd=0

(extra caharacters to satisfy 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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