Code:
import sys from tkinter import * credit = 0 coins = 0 choice = 0 credit1 = 0 coins = 0 prices = [200,150,160,50,90] item = 0 i = 0 temp=0 n=0 choice1 = 0 choice2 = 0 credit1 = 0 coins = 0 prices = [200,150,160,50,90] item = 0 i = 0 temp=0 n=0 choice1 = 0 choice2 = 0 def insert(): insert = Tk() insert.geometry("450x250") iLabel = Label(insert, text="Enter coins.[Press Buttons]").grid(row=1, column=1) tenbutton = Button(insert, text="10p").grid(row=2, column=1) twentybutton = Button(insert, text="20p").grid(row=3, column=1) fiftybutton = Button(insert, text="50p").grid(row=4, column=1) poundbutton = Button(insert, text="£1").grid(row=5, column=1) I am creating a program that simulates a vending machine. How would I tell Python to 'check' if A button has been pressed? In pseudocode it would be:
if tenbutton is pressed: Add 10p to credit How would I write in Python "if tenbutton is pressed"? Thank you in advance.