I dare you to also try to specify the index of everything you try to add For example : if i say sushi[1] then put it at the index 1 (not taking into account the 0 index....)
If .size() returns the size of the list, how come it doesn't replace the latest entry's index when used in .insert()? Apparently I can use END for the first argument of .insert() to add a new entry at the end of the list without weirding myself out.
this is one year later but basically: the list ["hot dog" , "pizza" ] has the size of 2 items but the index of the last item is actually 1 (because it starts at 0) so inserting the index 2 would be the 3rd item on the list
try cutting the delete button then paste it in a try...except clause idk if it helps try: deleteButton = Button(window,text="delete",command=delete) deleteButton.pack() except Exception: print("your text here") you should ask in stack overflow btw
# listbox = A listing of selectable text items within it's own container
def submit():
food = []
for index in listbox.curselection():
food.insert(index,listbox.get(index))
print("You have ordered: ")
for index in food:
print(index)
def add():
listbox.insert(listbox.size(),entryBox.get())
listbox.config(height=listbox.size())
def delete():
for index in reversed(listbox.curselection()):
listbox.delete(index)
listbox.config(height=listbox.size())
from tkinter import *
window = Tk()
listbox = Listbox(window,
bg="#f7ffde",
font=("Constantia",35),
width=12,
selectmode=MULTIPLE)
listbox.pack()
listbox.insert(1,"pizza")
listbox.insert(2,"pasta")
listbox.insert(3,"garlic bread")
listbox.insert(4,"soup")
listbox.insert(5,"salad")
listbox.config(height=listbox.size())
entryBox = Entry(window)
entryBox.pack()
frame = Frame(window)
frame.pack()
submitButton = Button(frame,text="submit",command=submit)
submitButton.pack(side=LEFT)
addButton = Button(frame,text="add",command=add)
addButton.pack(side=LEFT)
deleteButton = Button(frame,text="delete",command=delete)
deleteButton.pack(side=LEFT)
window.mainloop()
how to show the deleted items and remove from the box at the same time
Best video in the whole TH-cam. Not even kidding. Thanks a ton
You;re the goat bro code!!! saving my intro to comp grade rn 🐐🐐🐐🐐🐐
Best
Best channel yet, this is the best pre-course material ever. This smokes everything except coursera but in ways still out does coursera
Well Well ❤ thank you for the very helpful tutorials
I dare you to also try to specify the index of everything you try to add
For example :
if i say sushi[1] then put it at the index 1 (not taking into account the 0 index....)
Helpful and especially direct to the subject. I am a fan. Thank you.
you are the GOAT of coding,
love from earth 🌏
great video! loved coding along in this one
Nicely explained. But I did not see the usual comments added at the end of the code lines in this.
A useful video. Thanks bro.
how many centuries it takes to be like you bro?
thank you for such a great tutorial :)
Super video Bro! 🎉🎉
please can you make a guidance video of how to get in freelancing with coding
Fast, but really good. Thx
Your are best bro ....love from bangladesh
👍
Great tutorial! :)
We're going to break it Bro 👍👌
great show
If .size() returns the size of the list, how come it doesn't replace the latest entry's index when used in .insert()?
Apparently I can use END for the first argument of .insert() to add a new entry at the end of the list without weirding myself out.
this is one year later but basically:
the list ["hot dog" , "pizza" ] has the size of 2 items
but the index of the last item is actually 1 (because it starts at 0)
so inserting the index 2 would be the 3rd item on the list
can i copy all of this code?
Is there any way to make the columns resizable by clicking and dragging on top box in a column? (like you can most other prorgrams' listboxes)
Thank you 😁👍👍👍👍
Can someone explain the reversed thing, thats the only thing i find confusing.
Great vidéo.
Dropping comment down below!
Great!
bro it is very helpfull
Ty bro!
thanks!!!
شكرا
Wow!!!!
meow meow meow~!
can somebody help me how can I put exception handling when user did not select anything from the listbox but did click the delete button?
try cutting the delete button then paste it in a try...except clause
idk if it helps
try:
deleteButton = Button(window,text="delete",command=delete)
deleteButton.pack()
except Exception:
print("your text here")
you should ask in stack overflow btw
can somebody help me how can I put exception handling when user did not select anything from the listbox but did click the delete button?
can somebody help me how can I put exception handling when user did not select anything from the listbox but did click the delete button?
can somebody help me how can I put exception handling when user did not select anything from the listbox but did click the delete button?
can somebody help me how can I put exception handling when user did not select anything from the listbox but did click the delete button?