Example #1
0
File: gui.py Project: zdhoward/aud
 def process_window():
     global window
     global theme
     event, values = window.read()
     print("Event:", event)
     print("Values:", values)
     if event in (None, "Cancel", "Exit"):  # if user closes window or clicks cancel
         exit()
     elif event == "About":
         sg.Popup("About this software.")
     elif event == "_config_set_extensions_":
         ext_string = sg.PopupGetText("Extensions (separated by commas)")
         exts = ext_string.lower().replace(" ", "").replace(".", "").split(",")
         ## set extensions
     elif event == "_config_set_whitelist_":
         whitelist_string = sg.PopupGetText("Whitelist Files (separated by commas)")
         whitelist = whitelist_string.split(",")
         ## set whitelist
     elif event == "_config_set_blacklist_":
         blacklist_string = sg.PopupGetText("Blacklist Files (separated by commas)")
         blacklist = blacklist_string.split(",")
         ## set blacklist
     elif event == "_config_set_logfile_":
         logfile = sg.PopupGetText("Logfile", default_text=values["_selected_dir_"])
         ## set logfile
     elif event == "_backup_location_":
         if values[event]:
             sg.Popup(values[event])
         # run backup
     elif event == "_move_location_":
         if values[event]:
             sg.Popup(values[event])
         # run move
     elif event == "_copy_location_":
         if values[event]:
             sg.Popup(values[event])
         # run copy
     elif event == "_zip_location_":
         if values[event]:
             sg.Popup(values[event])
         # run zip
     elif event.find("::"):
         if event.split("::")[1].startswith("_change_theme_"):
             theme = event.split("::_change_theme_")[1]
             create_window()
         elif event.split("::")[1].startswith("_tools_"):
             if event.split("::_tools")[1] == "_afx_":
                 window.FindElement("_frm_tools_afx_").Update(visible=True)
                 window.FindElement("_frm_tools_name_").Update(visible=False)
                 window.FindElement("_frm_tools_convert_").Update(visible=False)
                 window.FindElement("_frm_tools_export_").Update(visible=False)
                 window.VisibilityChanged()
                 pass
             elif event.split("::_tools")[1] == "_name_":
                 window.FindElement("_frm_tools_afx_").Update(visible=False)
                 window.FindElement("_frm_tools_name_").Update(visible=True)
                 window.FindElement("_frm_tools_convert_").Update(visible=False)
                 window.FindElement("_frm_tools_export_").Update(visible=False)
                 window.VisibilityChanged()
                 pass
             elif event.split("::_tools")[1] == "_convert_":
                 window.FindElement("_frm_tools_afx_").Update(visible=False)
                 window.FindElement("_frm_tools_name_").Update(visible=False)
                 window.FindElement("_frm_tools_convert_").Update(visible=True)
                 window.FindElement("_frm_tools_export_").Update(visible=False)
                 window.VisibilityChanged()
                 pass
             elif event.split("::_tools")[1] == "_export_":
                 window.FindElement("_frm_tools_afx_").Update(visible=False)
                 window.FindElement("_frm_tools_name_").Update(visible=False)
                 window.FindElement("_frm_tools_convert_").Update(visible=False)
                 window.FindElement("_frm_tools_export_").Update(visible=True)
                 window.VisibilityChanged()
                 pass
     else:
         print("EVENT NOT FOUND: ", event)
Example #2
0
            comPort = e[0]
        comPorts[0].append(e[0])
        comPorts[1].append(e[1])
    return comPorts, comPort


# Sets the COM port the Arduino is connected to automatically or requests manual COM port input from user if not working
#
while(not arduinoConnected):
    try:
        comPorts, comPort = getSerialPorts()
        ser = serial.Serial(comPort, 9600)
        arduinoConnected = True
    except:
        # Automatic Arduino COM port detection failed so giving the user the possibility to manually enter the COM port
        comPort = sg.PopupGetText(('Connect your Arduino and enter Arduino COM port!\nAvailable hardware COM ports are:\n' + str(comPorts[0])), 'Enter COM port')
        comPorts = [], []
        if comPort == "Cancel" or comPort is None:
            exit()
        try:
            # Try to connect to the manually specified COM port
            ser = serial.Serial(comPort, 9600)
            arduinoConnected = True
        except:
            # Manual input of the COM port failed so giving the user the possibility to try again or leave
            decision = sg.PopupOKCancel("The COM port you entered is not available.\nClick OK to try again or Cancel to exit!")
            if decision == "Cancel" or decision is None:
                exit()
            

# **************************************** Defines the GUI *****************************************************************************************************