Ich habe mal versucht ein Spiel zu machen und arbeite am Menü. Nun wollte ich mit den Optionen anfangen und habe eingestellt, dass wenn man den Button "Options" drückt, die Buttons, welche man grade sehen kann, deaktiviert werden und ein neuer Hintergrund angezeigt wird. Nur wird mir anstatt eines Hintergrunds einfach ein blankes Tkinter fenster angezeigt. Weiß jemand, woran das liegen kann und wenn ja, woran?
Ich hoffe mir kann geholfen werden.
Code:
Code: Alles auswählen
from tkinter import *
import exceptions
#Window
root=Tk()
root.geometry('800x600')
root.title('Royal Island')
root.resizable(False,False)
root.iconbitmap('./assets/textures/root/icon.ico')
#Background
try:
background=PhotoImage(file='./assets/textures/root/menubg.png')
backgroundimg=Label(root,image=background)
backgroundimg.place(x=0,y=0,width=800,height=600)
except:
exceptions.nobgimg()
#Commands
def playbuttonaction():
print('I got here: Play')
def optionsbuttonaction():
optionsbutton.config(state=DISABLED)
playbutton.config(state=DISABLED)
try:
optionsbackground=PhotoImage(file='./assets/textures/root/options.png')
optionsbackgroundimg=Label(root,image=optionsbackground)
optionsbackgroundimg.place(x=0,y=0,width=800,height=600)
except:
exceptions.nobgimg()
#Buttons
playbuttonimg=PhotoImage(file='./assets/textures/root/Playbutton.png')
playbutton=Button(root,image=playbuttonimg,bd=0,command=playbuttonaction)
playbutton.place(width=200,height=40,x=290,y=237)
optionsbuttonimg=PhotoImage(file='./assets/textures/root/Optionsbutton.png')
optionsbutton=Button(root,image=optionsbuttonimg,bd=0,command=optionsbuttonaction)
optionsbutton.place(width=200,height=40,x=290,y=291)
root.mainloop()