Python Forum
Program strange behavior ( windows doesn't close) - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: Program strange behavior ( windows doesn't close) (/thread-18302.html)



Program strange behavior ( windows doesn't close) - adam2020 - May-12-2019

Hi guys,

I am working on a project for college I'm not sure if I'm allowed post the code and if I am allowed it's extremely long about 3'000 lines of code with multiple classes so it wouldn't be that trivial to post but I will provide all the information that is relevant and maybe someone could give me some theories as to why my program isn't working

I am using tkinter as the GUI

so I have a main window named root this does the bulk of the work but when a certain button is pressed this button will create a new window ( a smaller more static window) this window is created using the TK() function and again is called root but it is in a separate class, I have a function called build window() which handles the main.loop of this window and also destroys it if the x button is clicked. the problem I have while debugging is I noticed that when I don't close the smaller static window but close the window I cannot close the smaller static window, but if I close the smaller static window first then close the main window everything seems to be ok,

def mac_menu_select(self):
        print("MAC MENU FUNCTION")
        self.disable_window(True)
        print("MAC MENU FUNCTION 2")
        self.mac_menu_window = ViewMac(self, self.mac_spoofing_status)
        print("MAC MENU FUNCTION 3")
the ViewMac class's constructor has a method called buildWindow which takes care of the mainloop and also takes care of destroying the window when the x button is clicked.I have a debugging print statement to tell me if the window is being destroyed when I click the x button and it is indeed being destroyed,but it seems like only the first two prints() in mac_menu_select() are being called and the third one doesn't get printed until I destroy the main window, so why is it that the mac_menu_select method isn't terminating until I terminate the main window, I can click on this certain button numerous times lets say 5 times each time I click on it the first two print() methods get called and the program continues to run but when I terminate the main window the third print statement print("MAC MENU FUNCTION 3") will then be printed out 5 times,

any opinions on what may be happening?

thanks


RE: Program strange behavior ( windows doesn't close) - Yoriz - May-12-2019

You only want one mainloop, and one tk.TK instance, when you create your independent windows use tk.Toplevel instead of another tk.TK


RE: Program strange behavior ( windows doesn't close) - adam2020 - May-12-2019

thanks yoris

could you point me in the right direction maybe a good tutorial on this

thanks