
State_label = Label(data_frame, text="State")

Ln_label = Label(data_frame, text="Last Name") My_tree.tag_configure('evenrow', background="lightblue")ĭata_frame = LabelFrame(root, text="Record")ĭata_frame.pack(fill="x", expand="yes", padx=20)įn_label = Label(data_frame, text="First Name")įn_id(row=0, column=0, padx=10, pady=10)įn_id(row=0, column=1, padx=10, pady=10) My_tree.tag_configure('oddrow', background="white") My_tree.heading("Zipcode", text="Zipcode", anchor=CENTER) My_tree.heading("State", text="State", anchor=CENTER) My_tree.heading("City", text="City", anchor=CENTER) My_tree.heading("Address", text="Address", anchor=CENTER) My_tree.heading("ID", text="ID", anchor=CENTER) My_tree.heading("Last Name", text="Last Name", anchor=W) My_tree.heading("First Name", text="First Name", anchor=W) My_lumn("Zipcode", anchor=CENTER, width=140) My_lumn("State", anchor=CENTER, width=140)

My_lumn("City", anchor=CENTER, width=140) My_lumn("Address", anchor=CENTER, width=140) My_lumn("Last Name", anchor=W, width=140) My_lumn("First Name", anchor=W, width=140) My_tree = ("First Name", "Last Name", "ID", "Address", "City", "State", "Zipcode") My_tree = ttk.Treeview(tree_frame, yscrollcommand=tree_t, selectmode="extended") ,Ĭ.execute("""CREATE TABLE if not exists customers (Ĭ.execute("INSERT INTO customers VALUES (:first_name, :last_name, :id, :address, :city, :state, :zipcode)", Search_menu.add_command(label="Reset", command=query_database) Search_menu.add_command(label="Search", command=lookup_records) My_menu.add_cascade(label="Search", menu=search_menu) Option_menu.add_command(label="Exit", command=root.quit) Option_menu.add_command(label="Highlight Color", command=highlight_color) Option_menu.add_command(label="Secondary Color", command=secondary_color) Option_menu.add_command(label="Primary Color", command=primary_color) My_menu.add_cascade(label="Options", menu=option_menu) Highlight_color = colorchooser.askcolor()īackground=) My_tree.tag_configure('oddrow', background=secondary_color) Secondary_color = colorchooser.askcolor() My_tree.tag_configure('evenrow', background=primary_color) Search_button = Button(search, text="Search Records", command=search_records) Search_entry = Entry(search_frame, font=("Helvetica", 18)) Search_frame = LabelFrame(search, text="Last Name") My_tree.insert(parent='', index='end', iid=count, text='', values=(record, record, record, record, record, record, record), tags=('oddrow',))Ĭ.execute("SELECT rowid, * FROM customers WHERE last_name like ?", (lookup_record,)) My_tree.insert(parent='', index='end', iid=count, text='', values=(record, record, record, record, record, record, record), tags=('evenrow',)) # Create a database or connect to one that existsĬ.execute("SELECT rowid, * FROM customers") We’ll also add a reset feature that lets us reset the treeview with all the records.

We’ll then clear the treeview and return the results.

What do you do when you want to find a specific name in the customers database? In this video we’ll add a Search menu to the top of the screen and open a new window that allows us to type in a last name and search the database. In this video we’ll add a search database feature to our treebase app.
