Wywala błąd którego nie rozumiem.
Pytanie jak schować konsole?
Błąd jest przy błędnej odpowiedzi, czyli w
if decyzja == True:
print("tak") #początek aplikacji aplikacji
else:
root.destroy()
print("nie")#koniec apklikacji
#inport
from tkinter import messagebox
from tkinter import *
import random
import linecache
#okno
root = Tk()
root.resizable(0,0)
root.title("Wisielec")
root.geometry("800x600")
font = ("Ariel" ,20,"bold")
#alfabet
alphabet = "AĄBCĆDEĘFGHIJKLŁMNŃOÓPQRSŚTUVWXYZŻŹ"
#wspułrzendne
letter1X = 10
letter1Y = 260
letter2X = 10
#zmiene globalne
decyzja = ""
password = ""
errors = 0
passLabels = [] #pusta tablica do kratek
#logika
def gameOver():
over = "¡GAME OVER: GRA SKOŃCZONA!" " HASŁO TO: " +password+ " ¿CHCESZ DALEJ GRAĆ?"
if errors >= 12:
decyzja = messagebox.askyesno("GAME OVER",over)
if decyzja == True:
print("tak") #początek aplikacji aplikacji
else:
root.destroy()
print("nie")#koniec apklikacji
def randomText():
globals()["password"]
randomLiczba = random.randint(1,100)
wiersz = linecache.getline('password.txt', randomLiczba)
wiersz = wiersz.rstrip()
password = wiersz #mx 9 znakuw
password = password.upper()
return password
def wrongLetter():
globals()["errors"] += 1
if errors == 1:
ploton.create_line(20, 560 ,95 , 520, width = 10, fill = "black")
if errors == 2:
ploton.create_line(170, 560 ,95 , 520, width = 10, fill = "black")
if errors == 3:
ploton.create_line(95, 520 ,95 , 20, width = 10, fill = "black")
if errors == 4:
ploton.create_line(95, 20 ,245 , 20, width = 10, fill = "black")
if errors == 5:
ploton.create_line(245, 20 ,245 , 70, width = 10, fill = "black")
if errors == 6:
ploton.create_line(95, 150 ,170 , 20, width = 10, fill = "black")
if errors == 7:
ploton.create_oval(220, 70 ,270 , 120, width = 5)#glowa
if errors == 8:
ploton.create_line(245, 120 ,245 , 230, width = 5, fill = "black")
if errors == 9:
ploton.create_line(245, 150 ,205 , 190, width = 5, fill = "black")
if errors == 10:
ploton.create_line(245, 150 ,285 , 190, width = 5, fill = "black")
if errors == 11:
ploton.create_line(245, 230 ,205 , 270, width = 5, fill = "black")
if errors == 12:
ploton.create_line(245, 230 ,285 , 270, width = 5, fill = "black")
gameOver()
def checkLetter(event):
litera = event.widget["text"]
if litera in password:
index = 0
for letter in password:
if letter == litera:
event.widget["fg"] = "white"
event.widget["bg"] = "green"
litera = event.widget["text"]
etykieta = passLabels[index]
etykieta["text"] = litera
index += 1
else:
wrongLetter()
event.widget["fg"] = "red"
event.widget["bg"] = "black"
#interfejs
for letter in alphabet:
lbl = Label(root, text = letter, font = font, fg = "black", )
lbl.place(x = letter1X, y = letter1Y, width = 35, height = 35)
lbl.bind("<Button-1>", checkLetter)
letter1X += 40
if (letter1X > 405):
letter1Y += 80
letter1X = 10
password = randomText()
for letter in password:
lbl = Label(root, text = "", font = font, bg = "white", bd = 2, relief = "solid")
lbl.place(x = letter2X, y = 50, width = 40, height = 40)
letter2X += 45
passLabels.append(lbl)
ploton = Canvas(root, bg = "gold")
ploton.place(x = 450,y = 10, width = 340, height = 580)
root.mainloop()
Prosze o pomoc.