Всплывающее окно Python Tkinter запускается, но появляется только иногдаPython

Программы на Python
Anonymous
Всплывающее окно Python Tkinter запускается, но появляется только иногда

Сообщение Anonymous »

Мой метод Tkinter pop_up, похоже, работает сам по себе, как и ожидалось, и помещается в альтернативные строки метода, который его вызывает. Но при размещении в нужных местах всплывающее окно не отображается. Видно, что он запускается с отладочной распечаткой, но не появляется.

Код: Выделить всё

`  def pop_up(self, instruction):
root = Tk()
root.geometry("500x250")
root.title("Cheese Time")

def button_command():
global instruction_exe_time
t = strptime(entry.get()) # timeobject
instruction_exe_time= mktime(t) # time in seconds
self.set_time(instruction[0],instruction_exe_time)
print(ctime(instruction_exe_time))
root.destroy()

label_instruction = Label(root, text = instruction[1][0], font=('Helvetica 12 bold'))
label_instruction.pack(pady=20)
label = Label(root, text = "Enter time of execution:", font= ('Helvetica 10 bold'))
label.pack(pady= 10)

entry = Entry(root, width = 22, font=('Helvetica 14 bold'))
entry.insert(10,f"{ctime()}")
entry.pack(pady=10)

button = Button(root, text= "OK", command=lambda:button_command(), font= ('Helvetica 14 bold'))
button.pack(pady=20, padx=20)
root.mainloop()`

Код: Выделить всё

    # @threaded
def make_cheese(self):
print("Press enter to continue or 'A' to enter time of execution")

for instruc in self.instructions.items():
# self.pop_up(instruc) pop_runs when placed here also makes other pop_up calls run
if instruc[1][1] == True:
self.sleep_adjust(instruc[0])
#sleep(10) #instruc[1][2]
print(instruc[0], ": ", instruc[1][0])
self.pop_up(instruc) # does not work here
else:
# self.pop_up(instruc) pop_up also runs properly when placed here and makes other pop_ups run
print(instruc[0], ": ",instruc[1][0])
input1 = input()

if input1 == "A" or input1 == "a":
self.pop_up(instruc) # does not work here
else:
self.set_time(instruc[0],time())
self.set_done(instruc[0])
Метод pop_up, помещенный в альтернативные части метода, который его вызывает, запускает его, а затем правильно запускает другие вызовы в том месте, где это необходимо.
Что мешает показать это?

Подробнее здесь: https://stackoverflow.com/questions/784 ... s-shows-up

Вернуться в «Python»