#!/usr/bin/env python3 """ Debug the vars_dict issue in the edit window. """ import os import sys import tkinter as tk sys.path.insert(0, os.path.join(os.path.dirname(__file__), "src")) import logging from ui_manager import UIManager def debug_vars_dict(): """Debug what's in vars_dict when save is called.""" print("šŸ” Debugging vars_dict content...") root = tk.Tk() root.title("Debug Test") root.geometry("400x300") logger = logging.getLogger("debug") ui_manager = UIManager(root, logger) sample_values = ("07/29/2025", 5, 3, 7, 6, 1, "", 0, "", 0, "", 0, "", "Debug test") def debug_save(*args): print("\nšŸ” Debug Save Called") print(f"Number of arguments: {len(args)}") # The vars_dict should be accessible via the closure # Let's examine what keys are available print("\nTrying to access vars_dict from closure...") # Close window if args and hasattr(args[0], "destroy"): args[0].destroy() callbacks = {"save": debug_save, "delete": lambda x: x.destroy()} try: edit_window = ui_manager.create_edit_window(sample_values, callbacks) print("\nšŸ“ Instructions:") print("1. Add a dose to any medicine") print("2. Click Save to see debug info") edit_window.wait_window() except Exception as e: print(f"Error: {e}") import traceback traceback.print_exc() finally: root.destroy() if __name__ == "__main__": os.chdir("/home/will/Code/thechart") debug_vars_dict()