Aug-03-2020, 01:42 PM
from tkinter import * num_list = [] def add_num(): number = num_box1.get() if number.isdigit() == True: num_list.append(number) else: num_box1.delete(0,END) num_box2["text"] = num_list def clear(): num_list = [] num_box2["text"] = "" num_box2.delete(0,END) num_box1.delete(0,END) num_box1.focus() window = Tk() window.geometry("1000x500") num_box1 = Entry(text = "") num_box1.place(x = 150, y = 20, width = 125, height = 25) num_box1["bg"] = 'white' num_box1["fg"] = 'black' button1 = Button(text = "Enter a number", command = add_num) button1.place(x = 30, y = 20, width = 100, height = 25) button1["bg"] = "yellow" button1["fg"] = "purple" num_box2 = Message(text = num_list) num_box1.place(x = 150, y = 100, width = 125, height = 25) num_box1["bg"] = 'white' num_box1["fg"] = 'black' button2 = Button(text = "Enter a number", command = clear) button2.place(x = 30, y = 100, width = 100, height = 25) button2["bg"] = "yellow" button2["fg"] = "purple" window.mainloop()I'm using the above code but num_box1 isn't appearing in the window, can someone tell me why?
Thanks