ich bin recht neu in der python programmierung.
Zurzeit machen wir python in der Schule seit etwa einenm halben Jahr.
Nun sollen wir ein Spiel programmieren.
Wir haben uns Wer wird Millionär ausgesucht.
Aber wir haben ein Problem:
Wir haben Fragen mit 4 Antworten, eine ist richtig und öffnet eine neue Definition
bei der sich ein neues Fenster mit einer Frage und Antworten öffet.
Nur wie kann man das Fenster zuvor wieder schließen ohne es manuell zu tun
Code: Alles auswählen
from Tkinter import *
from random import *
def Frage50():
f50=Tk()
a="In welcher deutschen Stadt wurde der Reichstag verhüllt?"
b="Welches Tier hat das Baden Württenberg im Wappen?"
if randint(1,2)==1:
L1=Label(f50,text=a)
L1.pack(side='top')
b1=Button(f50,text='A:Bonn',command=f50.destroy)
b1.pack(side='top')
b2=Button(f50,text='B:Berlin ',command=Frage100)
b2.pack(side='top')
b3=Button(f50,text='C:Hamburg',command=f50.destroy)
b3.pack(side='top')
b4=Button(f50,text='D:München',command=f50.destroy)
b4.pack(side='top')
else:
L2=Label(f50,text=b)
L1.pack(side='top')
b5=Button(f50,text='A:Adler',command=f50.destroy)
b5.pack(side='top')
b6=Button(f50,text='B:Fisch ',command=f50.destroy)
b6.pack(side='top')
b7=Button(f50,text='C:Bär',command=f50.destroy)
b7.pack(side='top')
b8=Button(f50,text='D:Löwe',command=Frage100)
b8.pack(side='top')
f50.geometry('300x150-700+350')
f50.mainloop()
def Frage100():
f100=Tk()
c="Was gilt als König der Tiere ?"
d="Welches Tier rollt sich bei Gefahr zu einer Kugel?"
if randint(1,2)==1:
L3=Label(f100,text=c)
L3.pack(side='top')
b9=Button(f100,text='A:',command=f100.destroy)
b9.pack(side='top')
b10=Button(f100,text='B:Katze ',command=Frage500)
b10.pack(side='top')
b11=Button(f100,text='C:Schwein',command=f100.destroy)
b11.pack(side='top')
b12=Button(f100,text='D:Igel',command=f100.destroy)
b12.pack(side='top')
else:
L4=Label(f100,text=d)
L4.pack(side='top')
b13=Button(f100,text='A:Pferd',command=f100.destroy)
b13.pack(side='top')
b14=Button(f100,text='B:Katze ',command=frage500)
b14.pack(side='top')
b15=Button(f100,text='C:Schwein',command=f100.destroy)
b15.pack(side='top')
b16=Button(f100,text='D:Igel',command=f100.destroy)
b16.pack(side='top')
f100.geometry('300x150-700+350')
f100.mainloop()
menue=Tk()
mb2=Button(menue,text='Verlassen',command=menue.destroy)
mb2.pack(side='bottom')
mb=Button(menue,text='Spielen',command=Frage50)
mb.pack(side='bottom')
menue.geometry('300x150-700+350')
menue.mainloop()