vendredi 1 septembre 2023

Checkbox / Submit Logic issues

I have created a GUI using tkinter for an application deployer for my job. Im having an issue with 2 of my check boxes. I believe for some reason the Logic for my "Submit" button is getting confused

Ill elaborate...

When only selecting "Kaseya(AzureAD)" check box, then my submit button, In my logs I get

2023-09-01 12:51:09,465 - INFO - Currently selected options: []
INFO:main:Currently selected options: []
2023-09-01 12:51:09,466 - INFO - No options were selected.
INFO:main:No options were selected.

When only selecting "Trend(AzureAD)" check box, then my submit button, In my logs I get

2023-09-01 12:53:04,686 - INFO - Currently selected options: ['AzureAD']
INFO:main:Currently selected options: ['AzureAD']
2023-09-01 12:53:04,687 - INFO - Kaseya checkbox value for AzureAD: 0
INFO:main:Kaseya checkbox value for AzureAD: 0
2023-09-01 12:53:04,687 - INFO - Trend checkbox value for AzureAD: 1
INFO:main:Trend checkbox value for AzureAD: 1
2023-09-01 12:53:04,687 - INFO - Attempting to install TrendMicro
INFO:main:Attempting to install TrendMicro
ERROR:trend:Not connected to a domain. Current domain AzureAD FROM INSTALL_TREND()

The "Trend(AzureAD)" checkbox is working as expected, I have code to log the value of both active checkboxes when "Submit" button is pressed. Sense "Kaseya(AzureAD)" check box is not pressed it = 0.

When selecting both check boxes, then my submit button, In my logs I get

2023-09-01 12:54:32,387 - INFO - Currently selected options: ['AzureAD']
INFO:main:Currently selected options: ['AzureAD']
2023-09-01 12:54:32,388 - INFO - Kaseya checkbox value for AzureAD: 1
INFO:main:Kaseya checkbox value for AzureAD: 1
2023-09-01 12:54:32,389 - INFO - Trend checkbox value for AzureAD: 1
INFO:main:Trend checkbox value for AzureAD: 1
2023-09-01 12:54:32,389 - INFO - Attempting to install TrendMicro
INFO:main:Attempting to install TrendMicro
ERROR:trend:Not connected to a domain. Current domain AzureAD FROM INSTALL_TREND()
2023-09-01 12:54:32,390 - INFO - Attempting to install Kaseya
INFO:main:Attempting to install Kaseya
ERROR:kaseya:Not connected to a domain. Current domain AzureAD FROM INSTALL_KASEYA()

This is functioning as expected as well,

What doesn't make sense is why when I only select "Kaseya(AzureAD)" it comes back with no value in the check box and doesn't work but if "trend(AzureAD)" check box is selected as well, it works as expected.

Also don't be concerned with the ERROR, (AzureAD) is not a compatible domain for my install function. Its for Testing purposes and is working properly.

Below is my "Submit" button logic

def submit():
    global browser_checkboxes, kaseya_checkboxes, trend_checkboxes
    all_checkboxes = {**browser_checkboxes, **kaseya_checkboxes, **trend_checkboxes}
    selected_options = [option for option, var in all_checkboxes.items() if var.get() == 1]  

      # This line will log or print the selected options for debugging.
    logger.info(f"Currently selected options: {selected_options}")

    # checks if any Browser or Program has been selected to intall  
    if not selected_options:
        logger.info("No options were selected.")
        label.config(text="You have not selected any browsers or programs to install. Please select at least 1.")
        return
        
    # Check which Browsers to install and invoke the respective functions
    if "Chrome" in selected_options:
        logger.info("Attempting to install Chrome")
        install_chrome()
    if "Firefox" in selected_options:
        logger.info("Attempting to install Firefox")
        install_firefox()
        
    # Debugging logs to understand the values
    kaseya_selected = kaseya_checkboxes.get(domain_name).get()
    trend_selected = trend_checkboxes.get(domain_name).get()

    logger.info(f"Kaseya checkbox value for {domain_name}: {kaseya_selected}")
    logger.info(f"Trend checkbox value for {domain_name}: {trend_selected}")
    
    # Checks if Trend has been selected then calls the install_trend() from trend.py
    if trend_selected == 1:
        logger.info("Attempting to install TrendMicro")
        install_trend()

    # Checks if Kaseya has been selected then calls the install_kaseya from kaseya.py 
    if kaseya_selected == 1:
        logger.info("Attempting to install Kaseya")
        install_kaseya()



Aucun commentaire:

Enregistrer un commentaire