My code will not work unless I restart my kernel

So I am looking to create a mini GUI, where I need to configure certain vales. The first time I ran this tool it worked, however, when I run it again without a fresh kernel ran values are stuck at their default values. I think it could be a memory leak issue, but I am not sure how to check.

# -*- coding: utf-8 -*-
"""
Created on Mon Aug 26 08:55:59 2024

@author: khourym
"""

import tkinter as tk
from tkinter import ttk

# Function to create a top-level dropdown GUI and return dictionary on submit
def create_dropdowns(options, root):
    # This dictionary will hold the labels as keys and dropdown values as values
    result = {}

    def validate_float_input(char, text):
        """ Validate the input for the float entry. """
        print(char)
        if (
            all(char in "0123456789.-" for char in text) and  # all characters are valid
            "-" not in text[1:] and # "-" is the first character or not present
            text.count(".") <= 1): # only 0 or 1 periods
                return True
        else:
            return False

    def on_submit():
        # Update the result dictionary with the current dropdown selections
        for option, var in variables.items():
            print(var.get())
            
            result[option] = var.get()  # Get the current value of the dropdown

        # Get the value of the float entry
        sv_value = float_entry_var.get()

        top.destroy()  # Close the top-level window

        return result, sv_value

    # Create a top-level window
    top = tk.Toplevel(root, background="cyan")
    top.title("Top-Level Dropdown GUI")

    # Create a frame to hold all dropdowns
    infoFrame = tk.Frame(top,background="cyan")
    infoFrame.pack()
    cTile = tk.Label(infoFrame, text="Please configure the Control Logic states inn voltage with the VIH values and enter the nominal nvoltage for the supply voltage(VCC) all in volts",background="cyan")
    cTile.pack(expand=False, fill='both')
    frame = tk.Frame(top, background="cyan")
    frame.pack()

    # Create a dictionary to hold variables associated with dropdown values
    variables = {}
    
    # Iterate over the array of strings and create a label and dropdown for each
    for option in options:
        # Create a label for the string
        

        dropdown_label = tk.Label(frame, text="Enter the value for the control logic " + option, background="cyan") 
        dropdown_label.pack(anchor="w") # Create a variable to hold the selected value for each option 
        var = tk.StringVar(value="X") # default value is "X" 
        
        
        float_entry = tk.Entry(frame, textvariable=var) 
        float_entry.pack(anchor="w") # Store the variable in the dictionary with the option label as the key 
        variables[option] = var # Create a label and entry box for the float value 

    # Create a label and entry box for the float value
    float_label = tk.Label(frame, text="Enter The supply voltage VIH value", background="cyan")
    float_label.pack(anchor="w")

    float_entry_var = tk.StringVar(value="5.0")  # default value is "0.0"

    # Register the validation function
    vcmd = (root.register(validate_float_input), "%S", "%P")
    float_entry = tk.Entry(frame, textvariable=float_entry_var, validate="key", validatecommand=vcmd)
    float_entry.pack(anchor="w")

    # Create a submit button
    submit_button = tk.Button(top, text="Submit", command=on_submit, background="skyblue")
    submit_button.pack(pady=10)

    # Start the Tkinter main loop
    root.wait_window(top)

    # Return the result dictionary with the label-value pairs and the float value
    return result, float(float_entry_var.get())

    
if __name__ == "__main__": 

    # Example usage
    options_array = ["Option 1", "Option 2", "Option 3"]
    root = tk.Tk()
    root.withdraw()  # Hide the root window, only show the top-level window
    selected_values = create_dropdowns(options_array,root)
    print(selected_values)  # This will print the dictionary after you close the top-level GUI'''

with a fresh kernel: ({'Option 1': '4', 'Option 2': '4', 'Option 3': '7'}, 5.5)

not a fresh kernel: ({'Option 1': 'X', 'Option 2': 'X', 'Option 3': 'X'}, 5.0)

I am running this through spyder and the “restart kernel” is opening a new console through the app which in turn restarts kernel.

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật