0

I'm trying to remove the background of my buttons in tkinter. I have a background for the actual window but the buttons are hiding it.

image of application

Also help with spacing the buttons vertically would be nice.

Code for buttons:

button1 = Button(button_frame,text='1',font=('times new roman',12),relief='ridge',
           bd=0.3,bg='#e1e1e1',width=8,height=3,command=lambda:press(1))

Code for background:

bgimg = PhotoImage(file="Untitled-2.png")
my_label = Label(root, image=bgimg)
my_label.pack()
bad_coder
  • 11,289
  • 20
  • 44
  • 72
washere
  • 1
  • 3

1 Answers1

1

If you are trying to have buttons on top of the background image then you need to use Canvas like this.

However, within Tkinter, the Button widget does not support transparency. Here you will find some solutions for it but it is OS-dependant.

For positioning the widget you will need grid layout :

btnRun = Button(root, text='Run', command=myfunction)
btnRun.configure(state="disabled", fg="white")
btnRun.grid(row=4, column=0, padx=10, pady=20, ipadx=22)

You can adjust widgets like this in grid layout as per requirement.

Girish
  • 366
  • 3
  • 15
  • Bruh. Well thank you. This actually sucks though. Do you know how to add vertical spacing inbetween the buttons? That would be greatly appreciated. – washere Dec 22 '20 at 08:44
  • I have updated my answer for layout and positioning the widget – Girish Dec 22 '20 at 11:50