Jan-29-2025, 03:41 PM
ok so i'm building a reminder app for a client. So far i have one application that is booted by the user that the user can use to create reminders (send date, contact information, name, reminder description and send method are amongs my elements. Send method is defined by a drop down menu selection. My problem is with that function. I set the clicked variable to the dropdown menu and are retreving it. So far everything works as it should. I check if the clicked variable value is SMS and i assign the send method to SMS, otherwise the clicked value is Email. The problem is that no matter what my dropdown selection is the send method is always set to EMAIL!!!! can't figure out why. my relevant code follows
first i trigger this function by clicking the button
first i trigger this function by clicking the button
def save_info(self): saved_data = self.read_csv_file(self.CSV_FILE) send_date = self.send_date_ent.get() if not self.check_date(send_date): return name = self.name_ent.get().title() desc = self.description_ent.get() phone_number = self.phone_ent.get() if not self.check_alphabetical(name) or not self.check_alphabetical(desc): self.show_error(title="Error", message="Name or task description contains invalid characters. Please enter only alphabetical characters and spaces.") return have_email_address = self.var2.get() == 1 to_email_address = self.email_ent.get() if have_email_address else " not provided" if self.clicked=="SMS": if len(phone_number) != 11 or not phone_number.isdigit(): self.show_error(title="Error", message="Invalid phone number. Please enter a valid 11-digit UK phone number starting with 0.") return send_method="SMS" else: if have_email_address and not self.verify_email(to_email_address): self.show_error(title="Invalid Email", message="The email address you entered does not exist. Please enter a valid email address.") return send_method="Email" recurring = self.var1.get() == 1 end_date = self.end_date_ent.get() if recurring else "" if recurring and not self.check_date(end_date): self.show_error(title="OOOOOOps",message="End date is not in the right format,\nPlease enter a date in DD-MM-YYYY format!!") return self.process_save_info(saved_data, name, send_date, send_method, desc, phone_number, to_email_address, have_email_address, end_date, recurring)as you can see in the final line of that code i call another function. The latter function follows
def process_save_info(self, saved_data, name, send_date, send_method, desc, phone_number, to_email_address, have_email_address, end_date, recurring): '''this function is meant to aid the save info function if the reminder is recurring then the list of send dates is generated. if an email address is provided then it is saved along with all the other information as long as the user presses yes on the prompt.''' send_status=[] if recurring: frequency = simpledialog.askinteger(title="Task Frequency", prompt="How many days should the task occur?") start_date_index = self.dates_list_starting_from_today.index(send_date) end_date_index = self.dates_list_starting_from_today.index(end_date) send_dates = self.dates_list_starting_from_today[start_date_index:end_date_index:frequency] for date in send_dates: send_status.append("No") else: send_dates = send_date send_status.append("No") entry = { "name": name, "send date": send_dates, "send_method":send_method, "send status":send_status, "description": desc, "phone number": phone_number, "email address": to_email_address, "recurring": recurring, "have email address": have_email_address } if entry["send_method"]=="SMS": if messagebox.askyesno(title="Save Information", message=f"{name}? will be reminded to {desc} on {send_dates}\n" f"Their phone number is {phone_number}\n" f"\nWe will be sending this reminder via {entry['send_method']}!"): saved_data.append(entry) self.save_csv_file(self.CSV_FILE, saved_data) self.clear_widget_entries() messagebox.showinfo(title="Congratulations!!!!",message="Way to go!!\nYou have successfully saved this reminder!\n") else: if messagebox.askyesno(title="Save Information", message=f"{name} will be reminded to {desc} on {send_dates}\n" f"Their email address is {to_email_address}\n" f"\nWe will be sending this reminder via {entry['send_method']}!"): saved_data.append(entry) self.save_csv_file(self.CSV_FILE, saved_data) self.clear_widget_entries() messagebox.showinfo(title="Congratulations!!!!",message="Way to go!!\nYou have successfully saved this reminder!\n")my code seems to be constructed right but whether i select SMS or Email in the dropdown menu, the result is always Email. Please help if possible