Reputation: 19
I'm trying to make a to do list program on Python 3.8. It will take the inputs from the user by the help of
def input_():
label["text"] = inputword.get()
inputword=Entry()
inputword.pack(anchor = "nw", padx = 10, pady = 10)
and a button:
add_input= Button(text ="Add to List",
command = input_,
bg = "#ae0000",
fg= "white",
font=("Calibri", "15", "bold")
)
add_input.pack(anchor="nw", padx=10)
This works but i couldn't add my inputs to list.
listbox=Listbox()
listbox.place(x=250,y=250)
listbox.insert(0, add_input or maybe input_)
How should i rearrange my code?
Sample picture from my programL sample picture
Upvotes: 0
Views: 1127
Reputation: 15088
I think it should be like:
def input_():
label["text"] = inputword.get() #dont know what this is cuz label is undefined
listbox.insert(END, inputword.get()) #argument -> (index,string)
You can use the insert()
method of the Listbox
to insert into the Listbox
. This will insert each items to the end of the Listbox
, when you press the button. If you want each item to be on top rather than bottom of the list, then say 0 instead of END
.
Hope you understood whats going on, do let me know if any errors or doubts.
Cheers
Upvotes: 1