-1

I am making a simple program that also incorporates the use of TKinter. The inclusion is to have it copy and paste to my clipboard and also to check the contents of my keyboard. However, without much change from me, the console spits out an error :

can't invoke "event" command: application has been destroyed while executing 
"event generate $w <<ThemeChanged>>" (procedure "ttk::ThemeChanged" line 6)
invoke from within "ttk::ThemeChanged"` 

My questions:

  1. I do not understand what the error means;
  2. I do not understand how to fix it.

From my understanding, these error usually pop up from the use of matplotlib, which I am not using. The python console still can function after this message but it is annoying and distracting.

here is the code that i think is affecting it.

from Tkinter import Tk

r = Tk() 
r.withdraw() 
r.clipboard_clear() 
r.clipboard_append(finalbib) 
r.destroy()
#os.startfile("TEMPPY.py")
clipbardtest=True
while clipbardtest:
    r=Tk()
    clippytest = r.clipboard_get()
    r.destroy()
    if clippytest==finalbib:
        os.system('cls')
        print "Successfully copied to clipboard"
        #os.remove("TEMPPY.py")
        clipbardtest=False
        morebibdef()        
    else:
        time.sleep(1.2)
        #os.startfile("TEMPPY.py")
        r = Tk() 
        r.withdraw() 
        r.clipboard_clear() 
        r.clipboard_append(finalbib) 
        r.destroy()
John Hon
  • 183
  • 2
  • 10
  • The error is completely unrelated to matplotlib. It may be true that matplotlib causes these errors, but the errors can be caused by lots of different things. – Bryan Oakley Jan 27 '16 at 14:49
  • 1
    Look at https://stackoverflow.com/questions/45309090/cant-invoke-event-command-application-has-been-destroyed for a suggested solution. – Avner H. May 24 '19 at 18:02
  • Does this answer your question? [can't invoke "event" command: application has been destroyed](https://stackoverflow.com/questions/45309090/cant-invoke-event-command-application-has-been-destroyed) – chrstphrchvz Apr 25 '23 at 14:36

2 Answers2

1

See one of the comments from this question

If you use this in a console script this might lead to an error, that the .destroy() function will not work ("can't invoke "event" command: application has been destroyed while executing [...]"). To prevent this, call r.update() before r.destroy.

Community
  • 1
  • 1
Lewis
  • 1,310
  • 1
  • 15
  • 28
0

The error means that all of the tkinter windows have been destroyed, but that something is trying to generate an event. In order to generate an event you must have a window.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
  • is there anyway to fix this? I don't think I have any code that could be destroying a window. – John Hon Jan 29 '16 at 08:51
  • @JohnHon: it almost certainly can be fixed. However, I'm not very good at fixing code I cannot see. You should try to create an [MCVE](http://www.stackoverflow.com/help/mcve). – Bryan Oakley Jan 29 '16 at 12:18
  • sorry for the long wait, here's a sample piece of code that i think should be affecting it. i'm using the tkinter window to copy and evaluate the clipboard. i put the code in the question. – John Hon Mar 06 '16 at 07:56
  • @JohnHon: the code you posted a) doesn't run, and b) even if it did run, it cannot create the error you are reporting because it doesn't use the module that causes the error. – Bryan Oakley Mar 06 '16 at 14:06