Im trying to put 2 commands to 1 button so I can destroy one of the commands which is only text, when a another button is pressed. But is says:
Play = Button(text="Play!", lambda: [f() for f in [entry, playernames]])
^
SyntaxError: positional argument follows keyword argument.
heres the code, and it probably looks gross, but ive only been into coding for about 2 weeks.
from tkinter import *
from tkinter import filedialog, Text
import os
root = tk.Tk()
root.title("Number Guessing Game by Goasef")
#CANVAS
canvas = tk.Canvas(root, height=700, width=700, bg="#263D42", bd=0, highlightthickness=0)
canvas.pack(fill="both", expand=True)
canvas.create_text(350,70,fill="white",font=("Courier", 16, "italic"), text="THE NUMBER GUESSING GAME")
canvas.create_text(68,20,fill="white",font=("Arial", 12, "italic"), text="Game by Goasef")
def playernames():
# enter players names
canvas.create_text(83,300,fill="white",font=("Arial", 10, "italic"), text="Enter Player1 name: ")
canvas.create_text(83,350,fill="white",font=("Arial", 10, "italic"), text="Enter Player2 name: ")
def entry(): #entry
un_entry = Entry(root, font=("Arial"))
un1_entry = Entry(root, font=("Arial"))
un_entry.insert(0, "Player 1")
un1_entry.insert(0, "player 2")
def entry_clear(e):
if un_entry.get() == 'Player 1' or un1_entry.get() == 'Player 2':
un_entry.delete(0,END)
un1_entry.delete(0,END)
un_entry.bind("<Button-1>", entry_clear)
un1_entry.bind("<Button-1>", entry_clear)
def sg():
un1_entry.destroy()
un_entry.destroy()
Ok.destroy()
canvas.create_text(350,350,fill="white",font=("Helvetica", 16, "italic"), text="LET THE GAME BEGIN")
un_window = canvas.create_window(250, 300, window=un_entry)
un1_window = canvas.create_window(250, 350, window=un1_entry)
#ok button
Ok = Button(root, text="Ok!", font=("Arial", 8), width=5, command=sg)
Ok_window = canvas.create_window(380, 350, window=Ok)
#Play Button
Play = Button(text="Play!", lambda: [f() for f in [entry, playernames]])
Play.configure(width=10, activebackground="green", relief=FLAT)
Play_window = canvas.create_window(50,100, window=Play)
Play.pack()
# Quit Button
Quit = Button(text="Quit", command=quit)
Quit.configure(width=10, activebackground="red", relief=FLAT)
Quit_window = canvas.create_window(10,68, window=Quit)
Quit.pack()
canvas.pack()
root.mainloop()```
question from:
https://stackoverflow.com/questions/65643382/how-do-i-put-2-commands-in-1-button