I basically have a lot of different canvases that are all consequent to the other in order to create a game-like study guide. I wrote all canvases in functions given that it is schoolwork and with the click of every button the current canvas ereases and it jumps to the next canvas called by a function. My issue is that I also need to take into account correct answers to every question and doing so with a counter and I opted to go with a button because one can edit the configs --text-- that it displays.
def esp3():
canvase3=Canvas(window, width=750,height=537,bg='yellow')
canvase3.pack()
img = ImageTk.PhotoImage(Image.open("3esp.jpeg").resize((750, 537), Image.Resampling.LANCZOS))
canvase3.background = img
bg = canvase3.create_image(0, 0, anchor=tk.NW, image=img)
button1 = tk.Button(window, text="a", image=abutton, command=lambda: eligemateria() & canvase3.destroy())
button1 = canvase3.create_window(270, 280, anchor=tk.NW, window=button1)
button2 = tk.Button(window, text="b", image=bbutton, command=lambda: eligemateria() & canvase3.destroy())
button2 = canvase3.create_window(346, 280, anchor=tk.NW, window=button2)
button3 = tk.Button(window, text="c", image=cbutton, command=lambda: eligemateria() & canvase3.destroy())
button3 = canvase3.create_window(422, 280, anchor=tk.NW, window=button3)
Now, an example of something I would want to do is
button1 = tk.Button(window, text="a", image=abutton, command=lambda:[eligemateria(), canvase3.destroy(), correctabien()])
button1 = canvase3.create_window(270, 280, anchor=tk.NW, window=button1)
I've researched many methods but they only execute the first two functions in the command. I'd appreciate any input and if any context is needed I'm open to share more code or even other stuff I've tried.
Edit: The problem with the function to add a correct answer worked and thanks for the help but I have another instance where even though it executes the three tasks it shows an error in the terminal.
def creararchivoint():
canvasnew=Canvas(window, width=750,height=537,bg='yellow')
canvasnew.pack()
img = ImageTk.PhotoImage(Image.open("new.jpeg").resize((750, 537), Image.Resampling.LANCZOS))
canvasnew.background = img
bg = canvasnew.create_image(0, 0, anchor=tk.NW, image=img)
e1 = Entry(canvasnew)
canvasnew.create_window(380,360,window=e1, width=300, height=40)
button1 = tk.Button(window, text="Listo", command=lambda: [creacion(e1.get()), eligemateria() & canvasnew.destroy()])
button1 = canvasnew.create_window(359, 385, anchor=tk.NW, window=button1)
botonsal = tk.Button(canvasnew, text="Exit", image=imagbot2, command=lambda:window.quit())
botonsal = canvasnew.create_window(630, 50, anchor=tk.NW, window=botonsal)
The error it shows is:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\tkinter\__init__.py", line 1921, in __call__
return self.func(*args)
File "c:\Users\Rodri\Compu 1\yeet\codigo final.py", line 68, in <lambda>
button1 = tk.Button(window, text="Listo", command=lambda: [creacion(e1.get()), eligemateria() & canvasnew.destroy()])
TypeError: unsupported operand type(s) for &: 'NoneType' and 'NoneType'