![]() ![]() ![]() Print("Contacts sorted in descending order.") Select.insert(END, FirstName) # Insert the sorted contacts ![]() GuardianDirectory.sort(reverse=True) # Sort the list in descending order like I said some I have commented out for you to try and play about with it later… especially the dictionary one(I’ve commented using = just remember if you enable the dictionary functions to use you must disable the methods associated with a list)… nywho here is the code for sorting # sorting function Hey yeah it totally makes sense…but I thought I put everything in there did you check?. t(contact) # lastname is 2nd position in the lsit recall we are using index positioningīutton(root, text = 'Search Contact', font = 'arial 12 bold', bg = 'white', command = search).place(x=70, y=330)īutton(root, text = 'View Contact', font = 'arial 12 bold', bg = 'white', command = view).place(x=70, y=380)īutton(root, text = 'Reset', font = 'arial 12 bold', bg = 'white', command = clear_fields).place(x=280, y=350) # if contact is prsent we start retrieving and setting the variable to the associated values If search_result = contact: # since names are in the first positon, we are geetting items pos 0, feel free to change to variable you want to search with Search_result = FirstName.get() # searching the contact based on the first name and storing the search result # sorted_names = sorted(GuardianDirectory.keys()) Print("No contact selected for viewing.") Print("No contact selected for deletion.") I’ve also commented out the dictionary way of doing it as was pointing out but its too much work you’ll have to do an overhaul but if you ahve time play around with it… as for sorting I see it sorts itself automatically… nywy try the search functionality and good luck import sqlite3 I’ve addes a clear field function to clear everytime you add… So we will store the result of our search query to a search result variable but you can rename feel freely. Another thing you have assigned the result of your search query to the first name, which in this case is counterproductive as it overwrites the value of the firstname. First of you have duplicate search functionalities. ![]() Hi, I was going through your Tkinter app and its a nice for a start. place (x=30, y=220)Įntry(root, textvariable = Email).place (x=130, y=220)īutton(root, text = 'Add Contact', font = 'arial 12 bold', bg = 'white', command = add).place(x=70,y=280)īutton(root, text = 'Delete Contact', font = 'arial 12 bold', bg = 'white', command = delete).place(x=200, y=280)īutton(root, text = 'Search Contact', font = 'arial 12 bold', bg = 'white', command = view).place(x=70, y=330)īutton(root, text = 'Sort Contact', font = 'arial 12 bold', bg = 'white', command = selectset).place(x=200, y=330)īutton(root, text = 'Exit', font = 'arial 12 bold', bg = 'grey', command = exit).place(x=470, y=330) Label(root, text = 'Email', font = 'arial 12 bold', bg = 'white'). Label(root, text = 'Address', font = 'arial 12 bold', bg = 'white'). Label(root, text = 'Contact Number', font = 'arial 12 bold', bg = 'white'). Label(root, text = 'Last Name', font = 'arial 12 bold', bg = 'white'). Label(root, text = 'First Name', font = 'arial 12 bold', bg = 'white'). GuardianDirectory.append()ĬontactNumber.insert(0,GuardianDirectory)įIRSTNAME, LASTNAME, CONTACTNNUMBER, ADDRESS, EMAIL = GuardianDirectoryįor FirstName, LastName, ContactNumber, Address, Email in GuardianDirectory: Select.pack(side = LEFT, fill = BOTH, expand = 1) Select = Listbox (frame, yscrollcommand = t, height =15,) Scroll = Scrollbar(frame, orient = VERTICAL) This is my code so far, but I cannot figure out how to make the search and sort option work. I am new to Python and I have an assignment where we need to make a Phonebook with GUI. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |