I have a program that does mass spec data reduction. The workflow is:
- Present the user with a list of sequences, and ask them to select a sequence from the list.
- Once a sequence of analyses has been selected, the user is presented with a plot of the raw data to analyze.
For a while, this transition between the sequence selector GUI and the raw data GUI has been generating a cryptic error which looks like:
invalid command name "2073977167560update"
while executing
"2073977167560update"
("after" script)
invalid command name "2073972183304check_dpi_scaling"
while executing
"2073972183304check_dpi_scaling"
("after" script)
I have no idea what this means. Last time I saw it, I was using matplotlib.pyplot
instead of matplotlib.figure
in conjunction with tkinter. This time, I suspect it has to do with the transition between the GUIs, but I have no idea what I’m doing wrong or what I should be doing differently.
Here’s a minimal reproducible example:
from tkinter import ttk
import customtkinter as ctk
import matplotlib.figure as Figure
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
def create_first_gui():
window = ctk.CTk()
window.title('First GUI')
tree = ttk.Treeview(window)
tree["columns"]=("one","two")
tree.column("#0", width=100)
tree.column("one", width=100)
tree.column("two", width=100)
tree.heading("#0",text="Column A")
tree.heading("one", text="Column B")
tree.heading("two", text="Column C")
tree.insert("", 0, text="Line 1", values=("Random 1","Random 2"))
tree.pack()
button = ctk.CTkButton(window, text="Proceed to Second GUI", command=window.destroy)
button.pack()
window.mainloop()
def create_second_gui():
window = ctk.CTk()
window.title('Second GUI')
fig = Figure.Figure(figsize=(5, 4), dpi=100)
t = [i/100 for i in range(100)]
fig.add_subplot(111).plot(t, [i**2 for i in t])
canvas = FigureCanvasTkAgg(fig, master=window)
canvas.draw()
canvas.get_tk_widget().pack(side=ctk.TOP, fill=ctk.BOTH, expand=1)
window.mainloop()
create_first_gui()
create_second_gui()
The above script also produces a “click_animation” error:
invalid command name "2224692384648update"
while executing
"2224692384648update"
("after" script)
invalid command name "2224697676232check_dpi_scaling"
while executing
"2224697676232check_dpi_scaling"
("after" script)
invalid command name "2224697708616_click_animation"
while executing
"2224697708616_click_animation"
("after" script)