How To Use Spinbox For Selection Of Items In A List And Then Using Add To Cart Button To Add That Item To The Invoice?python 3
from tkinter import * These are two lists which has prices and product details. price_audible = ['$1.99', '$1.50', '$1.00', '$1.99', '$1.50', '$1.00', '$1.99', '$1.50',
Solution 1:
So when you click the Add to Cart button, the program should first get the value of the Spinbox, then use that data to get the price of the item from a list and add its price to another variable.
You can use spin_box.get()
to get the value from the Spinbox. To run a function on click, add the attribute command=your_function
to Button(dash_1, text = 'Add to cart').pack()
. Then you can add the function:
def your_function():
item_number = spinbox.get()
audible_cart_total_price += price_audible[item_number]
NOTE: You will have to change your data in price_audible
to be numbers, not strings. You can use string interpolation to add the dollar signs back when displaying to the screen.
Post a Comment for "How To Use Spinbox For Selection Of Items In A List And Then Using Add To Cart Button To Add That Item To The Invoice?python 3"