Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I want the buttons in the python code to be in directly under the change quantity amount. Can someone help me with the code for

I want the buttons in the python code to be in directly under the change quantity amount. Can someone help me with the code for editing the buttons position in the gui, here is the code i have tried:
# Create the GUI window
window = tk.Tk()
window.title("Shop Inventory")
window.geometry("600x600") # set fixed window size
# Load and display the company logo image
logo_image = Image.open("borton_fruit_logo.png")
logo_photo = ImageTk.PhotoImage(logo_image)
logo_label = tk.Label(window, image=logo_photo)
logo_label.grid(row=0, column=0, padx=10, pady=10, sticky='nw') # Place the label at the top left corner
# Callback function to close the database connection and exit
def on_closing():
db.close()
window.destroy()
# Set the callback function to be executed when the window is closed
window.protocol("WM_DELETE_WINDOW", on_closing)
# Create GUI components
item_combobox = ttk.Combobox(window, values=list(inventory.keys()))
item_combobox.set("Select Item")
# Label styling
label_style = ttk.Style()
label_style.configure("Custom.TLabel", font=("Arial",12),)
quantity_label = ttk.Label(window, text="Quantity: ", style="Custom.TLabel")
original_label = ttk.Label(window, text="Original Quantity: N/A", style="Custom.TLabel")
quantity_change_label = ttk.Label(window, text="Change Quantity:", style="Custom.TLabel")
quantity_change_entry = ttk.Entry(window)
new_label = ttk.Label(window, text="New Quantity: N/A", style="Custom.TLabel")
# Button styling
button_style = ttk.Style()
button_style.configure("Custom.TButton", font=("Arial",12))
button_width =5 # Adjust this value as needed
add_button = ttk.Button(window, text="\u2795 Add Quantity", command=add_quantity, style="Custom.TButton", width=button_width)
remove_button = ttk.Button(window, text="\u2796 Remove Quantity", command=remove_quantity, style="Custom.TButton", width=button_width)
save_button = ttk.Button(window, text="Save Changes", command=save_changes, style="Custom.TButton")
# Bind the item selection event to the item_selected function
item_combobox.bind(">", item_selected)
# Adding GUI components in the window using grid
item_combobox.grid(row=1, column=0, padx=10, pady=5, sticky='w')
quantity_label.grid(row=2, column=0, padx=10, pady=5, sticky='w')
quantity_change_label.grid(row=3, column=0, padx=0, pady=5, sticky='w')
quantity_change_entry.grid(row=3, column=0, padx=130, pady=5, sticky='w')
add_button.grid(row=4, column=1, columnspan=1, pady=5)
remove_button.grid(row=4, column=2, columnspan=1, pady=5)
original_label.grid(row=2, column=0, padx=0, pady=5, sticky='w')
new_label.grid(row=6, column=0, padx=0, pady=5, sticky='w')
save_button.grid(row=7, column=0, columnspan=2, padx=10, pady=5, sticky='w')
# Start the GUI application
window.mainloop()
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Server T-SQL Recipes

Authors: David Dye, Jason Brimhall

4th Edition

1484200616, 9781484200612

More Books

Students also viewed these Databases questions

Question

Under what circumstances are pay differentials justified?

Answered: 1 week ago