Skip to content

Commit

Permalink
guigroupsfixed full
Browse files Browse the repository at this point in the history
  • Loading branch information
dittko committed Apr 24, 2024
1 parent 1ab0dcc commit daaa54b
Showing 1 changed file with 43 additions and 16 deletions.
59 changes: 43 additions & 16 deletions interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,12 +408,38 @@ def add_contact(self, c: 'Contact'):
self.email_text.insert(INSERT, str(c.email) + "\n")

def add_contact_from_list_window(self):
def search_contact():
search_criteria = search_entry.get().strip().lower()
for widget in contact_inner_frame.winfo_children():
widget.destroy()
for idx, (email, name, surname) in enumerate(fake_data):
if search_criteria in name.lower() or search_criteria in surname.lower() or search_criteria in email.lower():
Label(contact_inner_frame, text=f"Mail {idx+1}:").grid(row=idx, column=0, padx=5, pady=5)
Label(contact_inner_frame, text=f"{email} - {name} {surname}").grid(row=idx, column=1, padx=5, pady=5)
Button(contact_inner_frame, text="Dodaj kontakt", bg="lightblue", fg="black", command=lambda email=email: add_contact_from_list(email)).grid(row=idx, column=2, padx=5, pady=5)

contact_window = Toplevel(self)
contact_window.title("Dodaj kontakt z listy")

group_editor_geometry = self.winfo_geometry()

contact_window.geometry(group_editor_geometry)

contact_frame = Frame(contact_window)
contact_frame.pack(fill=BOTH, expand=True)

search_frame = Frame(contact_frame, bg="lightblue")
search_frame.pack(fill=X, padx=5, pady=5)

search_label = Label(search_frame, text="Wyszukaj:", bg="lightblue")
search_label.pack(side=LEFT, padx=5, pady=5)

search_entry = Entry(search_frame, bg="white", fg="black")
search_entry.pack(side=LEFT, padx=5, pady=5, expand=True, fill=X)

search_button = Button(search_frame, text="Szukaj", bg="lightblue", fg="black", command=search_contact)
search_button.pack(side=LEFT, padx=5, pady=5)

scrollbar = Scrollbar(contact_frame, orient=VERTICAL)
scrollbar.pack(side=RIGHT, fill=Y)

Expand All @@ -426,28 +452,29 @@ def add_contact_from_list_window(self):
contact_canvas.create_window((0, 0), window=contact_inner_frame, anchor='nw')

fake_data = [("[email protected]", "John", "Doe"),
("[email protected]", "Jane", "Smith"),
("[email protected]", "Michael", "Johnson"),
("[email protected]", "Emily", "Brown"),
("[email protected]", "William", "Jones"),
("[email protected]", "Olivia", "Taylor"),
("[email protected]", "David", "Anderson"),
("[email protected]", "Sophia", "Thomas"),
("[email protected]", "James", "Jackson"),
("[email protected]", "Emma", "White"),
("[email protected]", "Benjamin", "Harris"),
("[email protected]", "Isabella", "Martin"),
("[email protected]", "Daniel", "Thompson"),
("[email protected]", "Ava", "Garcia"),
("[email protected]", "Alexander", "Martinez"),
("[email protected]", "TEST", "16")]
("[email protected]", "Jane", "Smith"),
("[email protected]", "Michael", "Johnson"),
("[email protected]", "Emily", "Brown"),
("[email protected]", "William", "Jones"),
("[email protected]", "Olivia", "Taylor"),
("[email protected]", "David", "Anderson"),
("[email protected]", "Sophia", "Thomas"),
("[email protected]", "James", "Jackson"),
("[email protected]", "Emma", "White"),
("[email protected]", "Benjamin", "Harris"),
("[email protected]", "Isabella", "Martin"),
("[email protected]", "Daniel", "Thompson"),
("[email protected]", "Ava", "Garcia"),
("[email protected]", "Alexander", "Martinez"),
("[email protected]", "TEST", "16"),
("[email protected]", "TEST", "17")]

def add_contact_from_list(email):
self.email_text.insert(END, email + "\n")

for idx, (email, name, surname) in enumerate(fake_data):
Label(contact_inner_frame, text=f"Mail {idx+1}:").grid(row=idx, column=0, padx=5, pady=5)
Label(contact_inner_frame, text=f"{email}").grid(row=idx, column=1, padx=5, pady=5)
Label(contact_inner_frame, text=f"{email} - {name} {surname}").grid(row=idx, column=1, padx=5, pady=5)
Button(contact_inner_frame, text="Dodaj kontakt", bg="lightblue", fg="black", command=lambda email=email: add_contact_from_list(email)).grid(row=idx, column=2, padx=5, pady=5)

def on_frame_configure(event):
Expand Down

0 comments on commit daaa54b

Please sign in to comment.