I am working on a basic selling manager
from tkinter import *
from PIL import Image,ImageTk
from tkinter import filedialog
screen = Tk()
screen.title("Buyer")
screen.geometry("800x600")
w = Frame(screen)
w.grid(padx=1, pady=1)
w.pack(pady=5)
def Add_image():
add_image.destroy()
image = filedialog.askopenfilename(initialdir="C:/Users/yasse/OneDrive/Documents",
filetypes=(("all","*.*"),("PNG","*.png"),("JPEG", "*.jpeg"),("GIF", "*.gif")))
Image.open(image).resize(size=(50,40))
photo = ImageTk.PhotoImage(image)
lbl = Label(w, image=photo).grid(column=0)
add_image = Button(w, text="+", font=("helvetica", 30), command= Add_image)
add_name = Entry(w, font=("helvetica", 13))
add_price = Entry(w, font=("helvetica", 13))
add_quantity = Entry(w, font=("helvetica", 16), width=5)
class product:
def __init__(self, image, name, price, quantity):
self.image = image
self.name = name
self.price = price
self.quantity = quantity
def product_row(self, row):
self.image.grid(column=0, row=row, padx=30, pady=15)
self.name.grid(column=1, row=row, padx=30, pady=15)
self.price.grid(column=2, row=row,padx=30, pady=15)
self.quantity.grid(column=3, row=row, padx=30, pady=15)
def selling():
buying_button.destroy()
selling_button.destroy()
screen.title("selling mode")
product1 = product(add_image, add_name, add_price, add_quantity)
product1.product_row(row=0)
product2 = product(add_image, add_name, add_price, add_quantity)
product2.product_row(row=1)
product3 = product(add_image, add_name, add_price, add_quantity)
product3.product_row(row=2)
buying_button = Button(w, text="buyer mode",font=("helvetica", 16), width=16, height=2)
selling_button = Button(w, text="seller mode",font=("helvetica", 16), width=16, height=2,
command= selling)
selling_button.pack()
buying_button.pack()
screen.mainloop()
so this code should create a multiple rows of products but for some reason only one product appears and I want also to replace the add_image button with the image but the image doesn't appears also