-4

hello i'm working on python using tkinter , i want to run a window (in Main) after destroy the first window in Login class , but the problem is that the code stop at the root.destroy and don't execute the reste of the code

i tried to replace root.destroy() by root.qui() , the rest of the code continue to execute but the first window still appear

from tkinter import *
import threading

class Login:
    def __init__(self):
        self.window=Tk()
        self.window.geometry("600x500+50+50")
        self.window.resizable(False,False)
        self.window.configure(bg="#fafafa")

    def start(self):
        self.window.mainloop()

    def stop(self):
        self.window.destroy()


class Main: 
    def __init__(self):
        self.login=Login()


   def test(self):
        a=input("a : ")
        b=input("b : ")

        if a ==b:
            self.login.stop()
        print("window destroyed .....")

test=Main()
threading.Thread(target=test.test).start()
test.login.start()
Antony
  • 1
  • 2
  • 2
    The code that you posted is totally unrelated to your question. – DYZ Jun 02 '19 at 05:23
  • @DYZ my question is clear and it's not related with the code , i'm just showing that the code stop executing when i call the function root.destroy stuated in the function login.stop() – Antony Jun 02 '19 at 05:29
  • 1
    Your question is not clear as such, and you make it even less clear by adding irrelevant code. Please provide a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). – DYZ Jun 02 '19 at 05:33
  • i don't know how you couldn't understant my question, it's clear , how my code continue executing after call root.destroy , because on my code it seems like it runs an infinit loop when i call root.destoy – Antony Jun 02 '19 at 05:37
  • 1
    Without seeing what `self.login.stop()` does, there's not much we can do to help. Under normal circumstances, code after that function should work just fine. If it's not, there's something in that function which you are not accurately describing. – Bryan Oakley Jun 02 '19 at 06:10
  • @BryanOakley the code is too long but i made a small code with the same situation of my code , it's below as an anwser – Antony Jun 02 '19 at 06:43
  • 2
    @abdou you can edit your question to put the code in it, not give it as answer. – Rahul Jun 02 '19 at 07:13
  • @DYZ i gave a small example of my code that gives the same problem could you see it please – Antony Jun 02 '19 at 07:14
  • @ReblochonMasque the "window destroyed ....." is printed just if the a is different of b , but if they have the same value the window destroyed but the code don't continue executing , it seems like it enter in infinit loop :) – Antony Jun 02 '19 at 12:59
  • ok, that is true @abdou, thanks for the precision. – Reblochon Masque Jun 02 '19 at 19:12

1 Answers1

0

finally i found a solution for the problem, in the method login.stop()

i replaced the instruction window.destroy() by window.after(0,window.destroy)

Antony
  • 1
  • 2