Python Forum
Program strange behavior ( windows doesn't close)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Program strange behavior ( windows doesn't close)
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")
        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?

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

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


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Noob question:Using pyttsx3 with tkinter causes program to stop and close, any ideas? Osman_P 4 2,184 Nov-14-2020, 10:51 AM
Last Post: Osman_P
  [Tkinter] How to close all windows when exit program scratchmyhead 3 2,642 May-17-2020, 08:19 AM
Last Post: menator01
  [Tkinter] Program with Multiple Windows - how to use Class: Riddle 1 1,399 Apr-09-2020, 08:30 PM
Last Post: Riddle
  How to close one of the windows in Tkinter scratchmyhead 3 2,192 Dec-21-2019, 06:48 PM
Last Post: pashaliski
  [PyQt] Close program using Push Button with the help of input from a Message Box bhargavbn 2 3,811 Oct-30-2018, 05:09 AM
Last Post: bhargavbn
  [Tkinter] program doesn't run. Doug 2 2,718 Jan-15-2017, 07:48 PM
Last Post: Doug

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020