def search_projects(): # get the vales from the box and from the combo type_ = seach_project_combo.get() search_text = search_projects_entry.get() if search_text == "" or type_ == "": print('Fill Both entrys') return global search_term if type_ == 'Customer Name': search_term = 'customer_name' # fire over to 'find customer' return all projects under matching customers elif type_ == 'Primay Contant': search_term = 'primary_conatact' # fire over to 'find contact' return all project under matching contact projects_found = 'primay constat' print('not yet implemented') elif type_ == 'Project Name': search_term = 'project_name' elif type_ == 'Refrence': search_term = 'project_refrence' elif type_ == 'Address': search_term = 'project_address' elif type_ == 'Post Code': search_term = 'project_postcode' elif type_ == 'Triage': search_term = 'project_triage' search_text = search_text if type_ == 'Customer Name' or type_ == 'Primary Contact': if type_ == 'Customer Name': display_search(Projects.search_by_cust_name(search_text)) else: results = Projects.find_project(search_text, search_term) display_search((Projects.find_project(search_text, search_term)))
def select_project(): # slect a project high lighted in the tree view # find the project based upon id, load from database focus = projects_tree.focus() project_selected = projects_tree.item(focus) global current_project, current_customer project_id = project_selected['values'][7] customer_id = project_selected['values'][8] current_customer = Customer.find_customer(customer_id, 'id')[0] current_project = Projects.find_project(project_id, 'project_id')[0] up_project_labels()
def expand_frame(task): # make a new function to disaplay a task in full view, contaning all info that is editible # get all info for the customer, the project, contacts etc. project_for_frame = Projects.find_project( task.project_id, 'project_id')[0] customer_for_frame = Customer.find_customer( project_for_frame.customer_id, 'id')[0] task_win = tk.Toplevel() task_win.wm_title( f'{task.task_description} :---: {project_for_frame.project_name} :---: {customer_for_frame.name} :---:' ) task_frame = ttk.Frame(task_win) #add some meaningfull info to the frame, make it editible and saveable to the database, #section for the customer #key contact deets, add contact to customer, change contact deets project_lable_frame = ttk.LabelFrame(task_frame, text='Project') project_lable_frame.grid(row=0, column=0) customer_lable_frame = ttk.LabelFrame(task_frame, text='Customer', padding=14.7) customer_lable_frame.grid(row=1, column=0) #get all the labels from customer #add allthe names and items to a dictinarry #make entrys (labeled - properley) for all relevetn customer items customer_labels = [ 'customer_name', 'customer_address', 'customer_postcode', 'customer_phone', 'customer_mobile', 'customer_email', 'customer_type', 'customer_id', ] customer_entry = {} customer_entry_label = {} for i, _name in enumerate(customer_labels): e = ttk.Entry(customer_lable_frame) entry[_name] = e e.grid(sticky='e', column=1) lb = ttk.Label(customer_lable_frame, text=_name[9:].title()) lb.grid(row=i, column=0, sticky='w') e.insert(0, getattr(customer_for_frame, f'{_name[9:]}')) project_labels = { 'Project Name': 'project_name', 'Project Reference': 'project_reference', 'Project Address': 'project_address', 'Project Postcode': 'project_postcode', 'Primary Contact': 'primary_contact', 'Project Type': 'project_type', 'Project Price Approx': 'project_price_approx', 'Project Expected Profit': 'project_expected_profit', 'Project Triage': 'project_triage', 'Project Lead MES': 'project_lead_mes', } for i, _name in enumerate(project_labels.keys()): e = ttk.Entry(project_lable_frame) entry[_name] = e e.grid(sticky='e', column=1) lb = ttk.Label(project_lable_frame, text=_name[8:]) lb.grid(row=i, column=0, sticky='w') # make something to convert list names to actual e.insert(0, getattr(project_for_frame, project_labels[_name])) #customer_name_entry.insert(0,customer_for_frame.name) task_frame.grid()