OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Why are there errors when I try to close a window in customtkinter?

  • Thread starter Thread starter ohshitgorillas
  • Start date Start date
O

ohshitgorillas

Guest
I have a very simple data window that I am trying to show and offer an exit button:

Code:
import customtkinter as ctk
import matplotlib.pyplot as plt
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg

# create the window using CTK
window = ctk.CTk()

# create the plot of random data
data = [1, 2, 3, 4, 5]
plt.plot(data)

# Add the plot to the window
canvas = FigureCanvasTkAgg(plt.gcf(), master=window)
canvas.draw()
canvas.get_tk_widget().pack(side='top', fill='both', expand=True)

exit_button = ctk.CTkButton(window, text='Exit', command=window.destroy)
exit_button.pack(side='bottom')  # add the exit button to the window

window.mainloop()

The problem is that after clicking Exit, while the window goes away, the terminal keeps running in the background with the following error:

Code:
invalid command name "2607166565512update"
    while executing
"2607166565512update"
    ("after" script)
invalid command name "2607167621640check_dpi_scaling"
    while executing
"2607167621640check_dpi_scaling"
    ("after" script)
invalid command name "2607249791944_click_animation"
    while executing
"2607249791944_click_animation"
    ("after" script)

What am I doing wrong and how can I get "Exit" to close the program completely?
<p>I have a very simple data window that I am trying to show and offer an exit button:</p>
<pre><code>import customtkinter as ctk
import matplotlib.pyplot as plt
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg

# create the window using CTK
window = ctk.CTk()

# create the plot of random data
data = [1, 2, 3, 4, 5]
plt.plot(data)

# Add the plot to the window
canvas = FigureCanvasTkAgg(plt.gcf(), master=window)
canvas.draw()
canvas.get_tk_widget().pack(side='top', fill='both', expand=True)

exit_button = ctk.CTkButton(window, text='Exit', command=window.destroy)
exit_button.pack(side='bottom') # add the exit button to the window

window.mainloop()
</code></pre>
<p>The problem is that after clicking Exit, while the window goes away, the terminal keeps running in the background with the following error:</p>
<pre><code>invalid command name "2607166565512update"
while executing
"2607166565512update"
("after" script)
invalid command name "2607167621640check_dpi_scaling"
while executing
"2607167621640check_dpi_scaling"
("after" script)
invalid command name "2607249791944_click_animation"
while executing
"2607249791944_click_animation"
("after" script)
</code></pre>
<p>What am I doing wrong and how can I get "Exit" to close the program completely?</p>
 

Latest posts

I
Replies
0
Views
1
impact christian
I
Top