def __init__(self, master): self.master = master self.search_frame = ttk.Frame(self.master) # bring the UI elements on the board self.search_lbl = ttk.Label(self.search_frame, text="Search Medicine", foreground='blue') self.qty_lbl = ttk.Label(self.search_frame, text="Qty", foreground='blue') self.search_lbl.grid(row=0, column=0) self.qty_lbl.grid(row=0, column=1) # self.search_entry = ttk.Entry(self.search_frame, width=40, foreground='black') # initialise the search entry with autocomplete try: all_drug_names = sql.session.query_drug_names_for_autocomplete() # print(all_drug_names) # prepare list to receive autocomplete source content autocomplete_source = [] for each_row in all_drug_names: # the autocomplete module accepts strings # so lets format the returned unicode to strings # and append that to the newly created list autocomplete_source.append(str(each_row[0])) self.search_entry = AutocompleteEntry(self.search_frame, width=40, foreground='black') # print(autocomplete_source) self.search_entry.set_completion_list(autocomplete_source) except IOError: print('Error processing data for autocomplete') # entry.pack() # entry.focus_set() self.search_entry.grid(row=1, column=0) self.search_entry.focus() self.qty_entry = ttk.Entry(self.search_frame, width=8, foreground='black') self.qty_entry.grid(row=1, column=1) self.search_btn = ttk.Button(self.search_frame, text="Search", command=self.search_drug) self.search_btn.grid(row=2, column=1) self.search_btn.bind() # pack them on the screen self.search_frame.pack(fill=BOTH, padx=10, pady=10) ########## search results to output here self.showInventoryFrame = ttk.Frame(self.master) self.showInventoryFrame.pack(expand=1, fill=BOTH, padx=10, pady=10) # imported table-like multi list box self.listBox = MultiListbox(self.showInventoryFrame, (("Drug Name", 30), ("Price (GHS)", 5), ("Qty", 5))) self.listBox.pack(expand=1, fill=BOTH) ########## search results to output here self.showTotalFrame = ttk.Frame(self.master) self.showTotalFrame.pack(fill=BOTH, padx=5, pady=5) self.total_lbl = ttk.Label(self.showTotalFrame, text="Total (GHS)", foreground='blue') self.total_lbl.pack(side=LEFT) self.total_entry = ttk.Entry(self.showTotalFrame, width=7, foreground='red') self.total_entry.pack(side=LEFT) ########## search operation buttons self.saleBtnsFrame = ttk.Frame(self.master) self.saleBtnsFrame.pack(fill=BOTH, padx=10, pady=5) self.delete_entry_btn = ttk.Button(self.saleBtnsFrame, text="Delete Entry", command=self.delete_entry) self.checkout_btn = ttk.Button(self.saleBtnsFrame, text="Checkout", command=self.checkout) self.checkout_btn.pack(side=RIGHT) self.delete_entry_btn.pack(side=RIGHT) self.clear_button = ttk.Button(self.saleBtnsFrame, text='Clear List', command=self.clear_sales_list) self.clear_button.pack(side=RIGHT) ## other init values # TODO: check (Am I polluting the 'self' namespace with all these bindings?) self.curr_pos = 0 self.all_items_pos = [] self.checkout_pressed = False ## the total_item_quantity stores the quantities of the # searched items displayed in the listbox for further calculations self.total_item_quantity = []