0

I want to delete all the background of the tkinter window and still leave all the other things I did in the window

from tkinter import *
win = Tk()
win.geometry("500x500")

Button = Button(win, text="Button", font=("ariel", 20))
Button.pack()


win.mainloop()

I want this button to stay and the background becomes transparent

user name
  • 1
  • 1
  • Does this answer your question? [Transparent background in a Tkinter window](https://stackoverflow.com/questions/19080499/transparent-background-in-a-tkinter-window) – Thingamabobs Dec 10 '22 at 16:08

1 Answers1

0

You can use destroy function The destroy() method in Tkinter destroys a widget. It is useful in controlling the behavior of various widgets which depend on each other. Also when a process is complete by some user action we need to destroy the GUI components to free the memory as well as clear the screen. The destroy() method achieves all this.

In the below example we have screen with 3 buttons. Clicking the first button closes the window itself where as the clicking of the second button closes the 1st button and so on. This behavior is emulated by using the destroy method as shown in the program below.

Example

from tkinter import *
from tkinter.ttk import *
#tkinter window
base = Tk()

#This button can close the window
button_1 = Button(base, text ="I close the Window", command = base.destroy)
#Exteral paddign for the buttons
button_1.pack(pady = 40)

#This button closes the first button
button_2 = Button(base, text ="I close the first button", command = 
button_1.destroy)
button_2.pack(pady = 40)

#This button closes the second button
button_3 = Button(base, text ="I close the second button", command = 
button_2.destroy)
button_3.pack(pady = 40)
mainloop()
  • Maybe I made a mistake in the definition, I meant that I want to make the screen transparent and that the button can still be seen – user name Dec 10 '22 at 16:33