Новое окно не появляется после того, как предыдущее окно было уничтожено. Либо следующий вызов функции не происходит, либо окно не появляется. Окно win4 не работает.
from string import ascii_lowercase
from wordfile import get_random_word
import tkinter as tk
from tkinter import Toplevel, Button, Label
window = tk.Tk()
window.title("WORD GAME")
def get_num_attempts():
win3 = tk.Tk()
win3.title("Number of attempts")
while True:
inp1 = tk.Label(win3, text="How many incorrect attempts do you want? [1-25] ")
inp1.pack()
inp1_feild = tk.Entry(win3)
inp1_feild.pack()
# b1 = tk.Button(win3, text="Enter", command=lambda: inp1_feild.get())
# b1.pack()
try:
num_attempts = inp1_feild.get()
num_attempts = int(num_attempts)
if(1 <= num_attempts <= 25):
return num_attempts
else:
out1 = tk.Label(win3, text='{0} is not between jmu1 and 25'.format(num_attempts))
except ValueError:
out1 = tk.Label(win3, text='{0} is not an integer between 1 and 25'.format(num_attempts))
Button(win3, text="Enter", command=win3.destroy).pack()
win3.focus_force()
win3.mainloop()
def get_min_word_length():
win4 = tk.Tk()
win4.title("Minimum Word Length")
while True:
inp2 = tk.Label(win4, text='What minimum word length do you want? [3-12] ')
inp2.pack()
inp2_feild = tk.Entry(win4)
inp2_feild.pack()
# b2 = tk.Button(win4, text="Enter", command=lambda: inp2_feild.get())
# b2.pack()
min_word_length = inp2_feild.get()
try:
min_word_length = int(min_word_length)
if(3 <= min_word_length <= 12):
return min_word_length
else:
out2 = tk.Label(win4, text='{0} is not between 3 and 12'.format(min_word_length))
except ValueError:
out2 = tk.Label(win4, text='{0} is not an integer between 3 and 12'.format(min_word_length))
Button(win4, text="Enter", command=win4.destroy).pack()
win4.mainloop()
def game():
rem_atmps = get_num_attempts()
min_word_length = get_min_word_length()
word = get_random_word(min_word_length)
heading_label1 = tk.Label(window, text="WANNA PLAY THE GAME ?? ....")
heading_label1.pack()
button1 = tk.Button(window, text="YES", command=lambda: game())
button1.pack()
button2 = tk.Button(window, text="NO", command=exit)
button2.pack()
window.mainloop()
Здесь, после нажатия кнопки ввода, вторая функция. т.е. get_min_word_length () не работает.