so I have a tkinter window with a play button
import tkinter
from play_function import *
window = tkinter.Tk()
screen_width = window.winfo_screenwidth()
screen_height = window.winfo_screenheight()
window.config ( width = screen_width )
window.config ( height = screen_height )
window.config ( background = "black" )
title = tkinter.Label ( window , text = "Scrabble" , background = "black" , foreground = "green" , font = ( "Comic Sans MS" , 200 ) )
title.pack()
play_button = tkinter.Button ( window , text = "PLAY" , background = "blue" , foreground = "black" , font = ( "Comic Sans MS" , 80 ) )
exit_button = tkinter.Button ( window , text = "EXIT" , background = "red" , foreground = "black" , font = ( "Comic Sans MS" , 77 ) , command = window.destroy )
play_button.config ( command= play ( title , play_button , exit_button ) )
space = tkinter.Label ( foreground = "black" , background = "black" , height = 2 , width = 50 )
play_button.pack()
space.pack()
exit_button.pack()
window.mainloop()
and I've made a separate file with a function for that button
import tkinter
def play (title , button_1 , button_2) :
title.destroy()
button_1.destroy()
button_2.destroy()
but because I need to give it some variables I open the parentheses and it calls the function
play_button.config ( command= play ( title , play_button , exit_button ) )
how can I fix this ?
what it does with my code is that it calls the function and destroy my buttons but what I would like it to do is only destroy the objects when I press the button