Search code examples
pythontkinterraspberry-pi3raspbian

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

a Screen shot of my raspberry screen

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)

Solution

  • 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.