Dateien nach "/" hochladen
Tic Tac Toe spiel mit ein paar bugs
This commit is contained in:
commit
3cfe2bb108
108
Tic Tac Toe.py
Normal file
108
Tic Tac Toe.py
Normal file
@ -0,0 +1,108 @@
|
||||
from tkinter import *
|
||||
root = Tk()
|
||||
root.geometry("900x500")
|
||||
|
||||
f1 = StringVar(value="1")
|
||||
f2 = StringVar(value="2")
|
||||
f3 = StringVar(value="3")
|
||||
f4 = StringVar(value="4")
|
||||
f5 = StringVar(value="5")
|
||||
f6 = StringVar(value="6")
|
||||
f7 = StringVar(value="7")
|
||||
f8 = StringVar(value="8")
|
||||
f9 = StringVar(value="9")
|
||||
Label(root, textvariable=f1, font=("times", 25)).grid(row=2, column=1)
|
||||
Label(root, textvariable=f2, font=("times", 25)).grid(row=2, column=2)
|
||||
Label(root, textvariable=f3, font=("times", 25)).grid(row=2, column=3)
|
||||
Label(root, textvariable=f4, font=("times", 25)).grid(row=3, column=1)
|
||||
Label(root, textvariable=f5, font=("times", 25)).grid(row=3, column=2)
|
||||
Label(root, textvariable=f6, font=("times", 25)).grid(row=3, column=3)
|
||||
Label(root, textvariable=f7, font=("times", 25)).grid(row=4, column=1)
|
||||
Label(root, textvariable=f8, font=("times", 25)).grid(row=4, column=2)
|
||||
Label(root, textvariable=f9, font=("times", 25)).grid(row=4, column=3)
|
||||
|
||||
def reset():
|
||||
f1.set(value="1")
|
||||
f2.set(value="2")
|
||||
f3.set(value="3")
|
||||
f4.set(value="4")
|
||||
f5.set(value="5")
|
||||
f6.set(value="6")
|
||||
f7.set(value="7")
|
||||
f8.set(value="8")
|
||||
f9.set(value="9")
|
||||
Label(root, text=" ").grid(row=8, column=2)
|
||||
def result():
|
||||
if f1.get() and f2.get() and f3.get() == "O":
|
||||
Label(root, text="Spieler 1 Gewinnt").grid(row=8, column=2)
|
||||
Button(root, text="Reset", command=reset).grid(row=9, column=2)
|
||||
|
||||
|
||||
|
||||
|
||||
def ok():
|
||||
zug=zug_wert.get()
|
||||
result
|
||||
if zug == "1":
|
||||
f1.set("O")
|
||||
result()
|
||||
elif zug == "2":
|
||||
f2.set("O")
|
||||
result()
|
||||
elif zug == "3":
|
||||
f3.set("O")
|
||||
result()
|
||||
elif zug == "4":
|
||||
f4.set("O")
|
||||
result()
|
||||
elif zug == "5":
|
||||
f5.set("O")
|
||||
result()
|
||||
elif zug == "6":
|
||||
f6.set("O")
|
||||
result()
|
||||
elif zug == "7":
|
||||
f7.set("O")
|
||||
result()
|
||||
elif zug == "8":
|
||||
f8.set("O")
|
||||
result()
|
||||
elif zug == "9":
|
||||
f9.set("O")
|
||||
result()
|
||||
|
||||
def ok1():
|
||||
zug1=zug1_wert.get()
|
||||
if zug1 == "1":
|
||||
f1.set("X")
|
||||
elif zug1 == "2":
|
||||
f2.set("X")
|
||||
elif zug1 == "3":
|
||||
f3.set("X")
|
||||
elif zug1 == "4":
|
||||
f4.set("X")
|
||||
elif zug1 == "5":
|
||||
f5.set("X")
|
||||
elif zug1 == "6":
|
||||
f6.set("X")
|
||||
elif zug1 == "7":
|
||||
f7.set("X")
|
||||
elif zug1 == "8":
|
||||
f8.set("X")
|
||||
elif zug1 == "9":
|
||||
f9.set("X")
|
||||
|
||||
|
||||
|
||||
|
||||
Label(root, text="TIC TAC TOE", font=("times", 25)).grid(row=0, column=2)
|
||||
Label(root, text="Spieler 1 ", font=("times", 25)).grid(row=1, column=0)
|
||||
Label(root, text="Spieler 2 ", font=("times", 25)).grid(row=1, column=7)
|
||||
zug_wert = Entry(root)
|
||||
zug_wert.grid(column=0)
|
||||
zug1_wert = Entry(root)
|
||||
zug1_wert.grid(row=5,column=7)
|
||||
|
||||
Button(root, text="OK", command=ok).grid(column=0)
|
||||
Button(root, text="Ok", command=ok1).grid(row=6, column=7)
|
||||
root.mainloop()
|
Loading…
x
Reference in New Issue
Block a user