Hi there, I currently ran into an error which I don't really understand as a beginner. I'm starting a small CTk Project and as I quit the window with command + q (on Mac) I always get the same Troubleshooting. Does anyone know what you can do about it?
Exception in Tkinter callback
Traceback (most recent call last):
File ".../anaconda3/envs/envapp/lib/python3.11/tkinter/init.py", line 1967, in call
return self.func(*args)
File ".../anaconda3/envs/envapp/lib/python3.11/tkinter/init.py", line 861, in callit
func(*args)
File ".../anaconda3/envs/envapp/lib/python3.11/site-packages/customtkinter/windows/widgets/scaling/scaling_tracker.py", line 178, in check_dpi_scaling
if window.winfo_exists() and not window.state() == "iconic":
File ".../anaconda3/envs/envapp/lib/python3.11/tkinter/init.py", line 1139, in winfo_exists
self.tk.call('winfo', 'exists', self._w))
_tkinter.TclError: can't invoke "winfo" command: application has been destroyed
Hi there, I currently ran into an error which I don't really understand as a beginner. I'm starting a small CTk Project and as I quit the window with command + q (on Mac) I always get the same Troubleshooting. Does anyone know what you can do about it?
Exception in Tkinter callback Traceback (most recent call last): File ".../anaconda3/envs/envapp/lib/python3.11/tkinter/init.py", line 1967, in call return self.func(*args)
File ".../anaconda3/envs/envapp/lib/python3.11/tkinter/init.py", line 861, in callit func(*args)
File ".../anaconda3/envs/envapp/lib/python3.11/site-packages/customtkinter/windows/widgets/scaling/scaling_tracker.py", line 178, in check_dpi_scaling if window.winfo_exists() and not window.state() == "iconic":
File ".../anaconda3/envs/envapp/lib/python3.11/tkinter/init.py", line 1139, in winfo_exists self.tk.call('winfo', 'exists', self._w))
_tkinter.TclError: can't invoke "winfo" command: application has been destroyed
Those line references aren't very helpful.
Μy current code looks like this:
` import tkinter import customtkinter
customtkinter.set_appearance_mode("System") # Modes: "System" (standard), "Dark", "Light" customtkinter.set_default_color_theme("green") # Themes: "blue" (standard), "green", "dark-blue"
----------------- Functions ---------------------------------
def change_appearance_mode_event(new_appearance_mode: str): customtkinter.set_appearance_mode(new_appearance_mode)
def change_scaling_event(new_scaling: str): new_scaling_float = int(new_scaling.replace("%", "")) / 100 customtkinter.set_widget_scaling(new_scaling_float)
----------------- Window Config ----------------------------
root = customtkinter.CTk() root.title("CustomTkinter complex_example.py") root.geometry(f"{1100}x{580}")
----------------- Grid Layout --------------------------------
root.grid_columnconfigure(1, weight=1) root.grid_columnconfigure((2, 3), weight=0) root.grid_rowconfigure((0, 1, 2), weight=1)
----------------- Left - Frame -------------------------------
sidebar_frame = customtkinter.CTkFrame(root, width=140, corner_radius=0) sidebar_frame.grid(row=0, column=0, rowspan=4, sticky="nsew") sidebar_frame.grid_rowconfigure(4, weight=1)
----------------- Header ---------------------------------
logo_label = customtkinter.CTkLabel(sidebar_frame, text="CustomTkinter", font=customtkinter.CTkFont(size=20, weight="bold")) logo_label.grid(row=0, column=0, padx=20, pady=(20, 10))
----------------- Config ---------------------------------
appearance_mode_label = customtkinter.CTkLabel(sidebar_frame, text="Appearance Mode:", anchor="w") appearance_mode_label.grid(row=5, column=0, padx=20, pady=(10, 0)) appearance_mode_optionemenu = customtkinter.CTkOptionMenu(sidebar_frame, values=["Light", "Dark", "System"],command=change_appearance_mode_event) appearance_mode_optionemenu.grid(row=6, column=0, padx=20, pady=(10, 10))
scaling_label = customtkinter.CTkLabel(sidebar_frame, text="UI Scaling:", anchor="w") scaling_label.grid(row=7, column=0, padx=20, pady=(10, 0)) scaling_optionemenu = customtkinter.CTkOptionMenu(sidebar_frame, values=["80%", "90%", "100%", "110%", "120%"],command=change_scaling_event) scaling_optionemenu.grid(row=8, column=0, padx=20, pady=(10, 20))
----------------- Locals ---------------------------------
appearance_mode_optionemenu.set("System") scaling_optionemenu.set("100%")
if name == "main": root.mainloop()`
It is pretty much the example Code broken down in some smaller pieces.