def grab_contact(self): """Inserts contact information into fields.""" name_entry = ab.get_contact(self.name) self.first_name.insert(0, str(name_entry[0])) self.last_name.insert(0, str(name_entry[1])) self.address1.insert(0, str(name_entry[2])) self.address2.insert(0, str(name_entry[3])) self.city.insert(0, str(name_entry[4])) self.state.insert(0, str(name_entry[5])) self.zip.insert(0, str(name_entry[6])) self.home.insert(0, str(name_entry[7])) self.mobile.insert(0, str(name_entry[8])) self.email.insert(0, str(name_entry[9])) self.birthday.insert(0, str(name_entry[10])) self.notes.insert(0, str(name_entry[11]))
def onSelect(self, event): """Displays contact information when user selects a contact from the contact list. """ w = event.widget try: name = str(self.book_list.get(self.book_list.curselection())) self.clearTextEntries() name_entry = ab.get_contact(name) self.first_name.insert(0, str(name_entry[0])) self.last_name.insert(0, str(name_entry[1])) self.address1.insert(0, str(name_entry[2])) self.address2.insert(0, str(name_entry[3])) self.city.insert(0, str(name_entry[4])) self.state.insert(0, str(name_entry[5])) self.zip.insert(0, str(name_entry[6])) self.home.insert(0, str(name_entry[7])) self.mobile.insert(0, str(name_entry[8])) self.email.insert(0, str(name_entry[9])) self.birthday.insert(0, str(name_entry[10])) self.notes.insert(0, str(name_entry[11])) # User cannot edit entry displayed on main GUI, unless clicking edit # button. self.first_name.configure(state='readonly') self.last_name.configure(state='readonly') self.address1.configure(state='readonly') self.address2.configure(state='readonly') self.city.configure(state='readonly') self.state.configure(state='readonly') self.zip.configure(state='readonly') self.home.configure(state='readonly') self.mobile.configure(state='readonly') self.email.configure(state='readonly') self.birthday.configure(state='readonly') self.notes.configure(state='readonly') except: return
import phonebook import logger import sys program = True args = sys.argv while program: new_contact = phonebook.create_contact() phonebook.add_contact(phonebook.repertoire, new_contact) next_name = input("Rentré un nouveau numéro ? ") if next_name == "Non": program = False phonebook.console_print() for i in range(0, len(args)): if (args[i] == "-display") and (len(args) > i + 1): phonebook.get_contact(args[i + 1], phonebook.repertoire) for i in range(0, len(args)): if args[i] == "-log": logger.dump_log()
import phonebook as p import logger as l k = "defkjenkf" c = p.create_contact('Kilian', '0769062552', True) p.add_contact(c) c = p.create_contact('Max', '0145935203', False) p.add_contact(c) c = p.create_contact('Lucie', '0967203628', False) p.add_contact(c) c = p.create_contact('Faycal', '0783429508', True) p.add_contact(c) c = p.create_contact('Charles', None, False) p.add_contact(c) print(p.annuaire) print(p.get_names()) p.display_all() try: p.get_contact(k) except KeyError as ke: print(ke) try: l.dump_log() except FileNotFoundError as fnfe: print(fnfe)
import phonebook as P import logger as l import sys #import utils #Import du module #from utils import say_hello P.get_names() P.display_all() try: print(P.get_contact("064333234")) except KeyError as e: print(f'erreur : {e}') try: args = sys.argv arg1 = args[1] arg2 = args[2] arg3 = args[3] except IndexError as e: print("erreur") if arg1 == "-log": l.dump_log() #elif try: # if arg2 == "-display" and arg3 == "097865434": if arg2 == "-display": print(P.get_contact(arg3)) # print(P.get_contact("097865434"))
from art import * import phonebook import logger phonebook.annuaire phonebook.get_names() phonebook.display_all() phone = input ("ton num") phonebook.get_contact(phone) logger.dump_log()