Error: _tkinter.TclError: can't invoke "wm" command: application has been destroyed
All that message means is that you're calling one of the "wm" commands (eg: wm_title, wm_geometry, and a few others) after you've destroyed the root window. (note: "geometry" and "title" are simple shortcuts to "wm_geometry" and "wm_title").
You're using tkinter in a highly unusual way. Tkinter was designed for you to create a single instance of Tk, and call mainloop exactly once. Is there a reason why you need to stop and start Tkinter multiple times in the course of your application? If all you need to do is pop up some modal dialogs and wait for the user to enter data, you can do that without creating a new instance of Tk every time.
WEshruth
Updated on June 05, 2022Comments
-
WEshruth almost 2 years
I have three classes on three different files, to get User inputs through GUI
#file1 class GetInfo1(): def getInfo1(): #my code return info1 #file2 class GetInfo2(): def getInfo2(): #my code return info2 #file3 class GetInfo3(): def getInfo3(): #my code return info3
calling these methods from different file
Getinformation.py
that file would befrom GetInfo1 import * from GetInfo2 import * from GetInfo3 import * object1 = GetInfo1() getInfor1 = object1.getInfo1() print getInfor1 object2 = GetInfo2() getInfor2 = object2.getInfo2() print getInfor2 object3 = GetInfo3() getInfor3 = object3.getInfo3() print getInfor3
Classes are as follows:
from Tkinter import * root = Tk() app = Frame(root) entry = Entry(app) entry.grid() class GetInfo1(): def OnClick(self): global input1 input1 = entry.get() #print ("You have entered %s"%input1) root.destroy() return input1 def getInfo1(self): '''Window''' global input1 root.title("Input Permutation Range ") root.geometry("300x200") app.grid() label = Label (app, text="Please Enter the propogation range ( 2 - 4)") label.grid() '''Button''' Object2 = AskPermutationRange() button = Button (app, text="Submit", command=Object2.OnClick) button.grid() root.focus_set() root.mainloop() return input1
Getting
getInfor1
,getInfor2
as specified but while running third object getting error_tkinter.TclError: can't invoke "wm" command: application has been destroyed
How can i re invoke app again. thanks in advance