if strChoice.strip( ) == '1': # Show user current data in the list of employee objects for row in lstTable: line = row.to_string() print(row.to_string()) continue # to show the menu elif strChoice == '2': # Let user add data to the list of employee objects addEmp = Eio.input_employee_data() print(addEmp.first_name + " has been added") lstTable.append(addEmp) continue # to show the menu elif strChoice == '3': # let user save current data to file strChoice = Eio.input_yes_no_choice("Save this data to file? (y/n) - ") if strChoice.lower() == "y": Fp.save_data_to_file("EmployeeData.txt", lstTable) #use write data function else: print("Save Cancelled!") continue # to show the menu elif strChoice == '4': # Let user exit program print("Goodbye!") break # and Exit else: print("Error! Please input a menu option: [1] to [4]") # Main Body of Script ---------------------------------------------------- #
Eio.input_press_to_continue() # send a message to the user elif strChoice == '2': # Enter New Employee ID's and names while True: # Use a While loop to allow for continued data entry # Use this Eio function to input a new Employee Id and Name Info strNewEmp = Eio.input_employee_data( lstTable) # Input New Employee Info here strEmpInfo = str( strNewEmp ) # Took the returned Employee info and set to this string variable here empID, empFirstName, empLastName = strEmpInfo.split( ",") # Split out the various string pieces here # Print show the data for the new employee that was added print("New Employee Added: " + "ID: " + empID + " - " + empFirstName + " " + empLastName) # Evaluate the user choice and exit loop if "n" in response if "n" in Eio.input_yes_no_choice(): print() # Add a line here for readability # Exit the loop and go to the Main Menu break else: print() elif strChoice == '3': # Save Data to File # Evaluate the user choice and exit loop if "y" in response if "y" in Eio.input_yes_no_choice( "Save New Employee data to file? (y/n) - " ): # Use choice Eio function # If the user enters "y" get the filename and task list table and user the Processor function # to write to a text file Fp.save_data_to_file(strFileName, lstTable) strStatus = "Data Saved!!" # Pass this message to the IO function below Eio.input_press_to_continue(strStatus)