List Boxes - Python Tkinter GUI Tutorial #61

Поделиться
HTML-код
  • Опубликовано: 5 фев 2025
  • In this video we'll learn about List Boxes with Tkinter and Python.
    A list box is a box that holds a list of items. It's a tkinter widget that can be used for all sorts of things. In this video I'll show you how to create one, how to add items to a listbox, how to select items from a listbox, and how to delete items from a listbox.

Комментарии • 139

  • @Codemycom
    @Codemycom  4 года назад +3

    ▶️ Watch Entire Tkinter Playlist ✅ Subscribe To My RUclips Channel:
    bit.ly/2UFLKgj bit.ly/2IGzvOR
    ▶️ See More At: ✅ Join My Facebook Group:
    Codemy.com bit.ly/2GFmOBz
    ▶️ Learn to Code at Codemy.com ✅ Buy a Codemy T-Shirt!
    Take $30 off with coupon code: youtube1 bit.ly/2VC9WUN

    • @shubhgaur2805
      @shubhgaur2805 3 года назад

      Good Morning, Sir can you help us by preparing a video on embed live graph in Tkinter using CSV file and without using CSV file

  • @noice1031
    @noice1031 4 года назад +20

    This deserves more views brilliant videos.

    • @Codemycom
      @Codemycom  4 года назад +4

      Thanks! Tell your friends ;-)

  • @AI_For_Scientists
    @AI_For_Scientists 3 года назад

    thank for making these things so easy. for someone who doesnt work with these all the time you videos are gold to hit the ground and make something cool.🙏

    • @Codemycom
      @Codemycom  3 года назад

      Glad you're enjoying them!

  • @EiswaffelGHG
    @EiswaffelGHG Год назад

    Just.. thank you for everything, John! I used to hate tkinter, but with your help.. i kind of like it!

  • @Lennardish
    @Lennardish 2 года назад

    Hello John, I am bald, like you, and I always bump somehow my head, which is very often leaving traces :)
    We, bald headed people, suffer a lot from objects that always seem to hang where they should not be :)))
    I enjoy this video about listboxes and doing stuff with them. Thank you!!!

    • @Codemycom
      @Codemycom  2 года назад

      Ha, I just hit my head on something yesterday lol

  • @spike666spike666
    @spike666spike666 Год назад

    Yo I watch and re-watch your videos. Awesome job! I only wish to be as skilled as you! Each video I watch I learn something new. Keep them coming!

  • @austinccolton
    @austinccolton 4 года назад +3

    Smashed the Like Button! Thanks man, your channel has helped me do something I never thought I would have been able to. You're the best!

    • @Codemycom
      @Codemycom  4 года назад

      Very glad to hear it!

  • @naveenvaddi9707
    @naveenvaddi9707 4 года назад +4

    Hey John, Thanks a ton for all the Tkinter Video man! I used almost every widget from your videos for my personal project, thanks again :) I've added your YT list to my list for reference.
    I just have a small request, could you please try to make a video on how to play around with 'window' sizes and how to move widgets to center (even after maximizing the entire window) and how to make the window full screen by default.
    Thanks much again 👍

    • @Codemycom
      @Codemycom  4 года назад +2

      Yeah i need to do some videos on sizing...

  • @kulubrimbor
    @kulubrimbor 4 года назад +1

    Thank you for this series in usual. You saved my project. Thx

    • @Codemycom
      @Codemycom  4 года назад

      You're very welcome! Glad you enjoyed the videos!

  • @insertx2k_dev
    @insertx2k_dev 3 года назад

    Thank you for such an awesome tutorial!, I hope you really get more than your current amount of subscribers as you deserve more!

    • @Codemycom
      @Codemycom  3 года назад

      Thanks, tell your friends ;-)

  • @jefflee7704
    @jefflee7704 2 года назад

    Thank you ever so much for your tutorials much appreciated

    • @Codemycom
      @Codemycom  2 года назад

      Thanks for watching!

  • @premprasad3511
    @premprasad3511 2 года назад

    Very clear explanation. Thank you

  • @whiteflag2366
    @whiteflag2366 3 года назад

    Very cool. Thanks for sharing!

  • @tannerjohnston7762
    @tannerjohnston7762 4 года назад +5

    Loving these videos, John! Could you do a tutorial on how to save and display images in a listbox on Tkinter? For example: using a dialog box I select 5 jpg or png files and have them all appear in the listbox as 'thumbnails'. Thanks!

    • @Codemycom
      @Codemycom  4 года назад +2

      Interesting idea, can you display images in a listbox?

    • @anassportal
      @anassportal 2 года назад

      You read my thoughts

  • @2050bundele
    @2050bundele 4 года назад

    This is very helpful , thankyou john

    • @Codemycom
      @Codemycom  4 года назад

      Glad You're enjoying it!

  • @charantechgeek
    @charantechgeek 4 года назад +2

    Hello sir(Jhon elder).You are my favorite teacher in teaching GUI Development.Thank you. I've seen every video on GUI development in ur utube channel and I am inspired to build a project.
    I am currently working on a project and I encountered a problem.I want a table to show the result (marks of each subject)of a class.As tkinter has no Table widget,so I tried using the Grid geometry and scrollbar but the text is shrinking and overlapping with increase in number of students(rows).could you please help me with this?

    • @Codemycom
      @Codemycom  4 года назад +1

      Sorry I can't know what's going on...you'll have to just dig thru and figure it out :-)

    • @charantechgeek
      @charantechgeek 4 года назад

      @@Codemycom thanks for your response

  • @aimannabil6447
    @aimannabil6447 4 года назад +1

    Hey John, amazing tuts. You earned a subscriber. Quick question, how do you update listbox in a thread?

    • @Codemycom
      @Codemycom  4 года назад

      In a thread?

    • @aimannabil6447
      @aimannabil6447 4 года назад

      ​@@Codemycom Talking about concurrent programming but never mine I got it figure it out

    • @Codemycom
      @Codemycom  4 года назад

      @@aimannabil6447 Gotcha

  • @Abdulaziz-e-2030
    @Abdulaziz-e-2030 4 года назад

    hello teacher I have a question in minute 10:35 __ why you should write global ((my_label))?

  • @Potatostarch300
    @Potatostarch300 Год назад

    hello, thanks for the video. How would you create a numbered list where the number auto-populates as you type the next line?

    • @Codemycom
      @Codemycom  Год назад

      I don't have any videos on that

  • @codefoxx
    @codefoxx 4 года назад

    U deleted items from the listbox but not from the list, when you re-run the program, the items are there again. How do we delete an item from the listbox and the list simultaneously so it does not re-appear when we re-run? I ask because I'm bringing in songs from a text file for a music player project. When the user deletes a song from the listbox (his Playlist) , I want it to delete from the text file as well. I can figure it out if you point me in the right direction. Thank you sir!

    • @Codemycom
      @Codemycom  4 года назад

      You don't. Unless the data is coming from a database (and then you can delete it), it will always be there when you re-run the program...it's hard coded there. In your case, you'd need to delete them from the text file.

    • @codefoxx
      @codefoxx 4 года назад

      @@Codemycom that's easier said than done. How do I know which item the user deleted from the listbox? Is there a way to check which items are in the listbox by index maybe? For example, listbox[0]?

    • @codefoxx
      @codefoxx 4 года назад

      If there is, maybe I can just update my text file with the current items on the listbox

  • @justpourlapai3227
    @justpourlapai3227 2 года назад

    Hello!! is it possible to display a second list boxes by selecting a value in a first list boxes?

    • @Codemycom
      @Codemycom  2 года назад

      of course. I have videos on dependent list boxes

  • @nobodyeverybody8437
    @nobodyeverybody8437 3 года назад

    Would u plz show how to bind an event listener to the listbox to automatically detect the selected item?

  • @נועהבינסקי
    @נועהבינסקי 3 года назад

    thank you so much for those tutorials. it helps a lot. i wonder if there is a way to return the results into a variable, not only to print them into the tkinter screen. i've looked everywhere and didnt find. can you help me please???

    • @Codemycom
      @Codemycom  3 года назад +1

      pretty sure I have videos on that in the playlist...

    • @נועהבינסקי
      @נועהבינסקי 3 года назад

      @@Codemycom thank you
      I will check 🙏

  • @salahroualmi9753
    @salahroualmi9753 2 года назад

    get anchor would work if used in a function then later on called, but in case print(l.get(anchor)) was just written at the end the code would not print every time I select and anchor any idea why?

  • @JohnSmithZen
    @JohnSmithZen Год назад

    Is there any way to make the columns resizable by clicking and dragging on the edge of the top box in a column? (like you can most other prorgrams' listboxes)

  • @MD-cu8tt
    @MD-cu8tt 4 года назад +1

    Thank you brother !

    • @Codemycom
      @Codemycom  4 года назад

      You are very welcome

  • @vincenzo3292
    @vincenzo3292 4 года назад

    Can you recommend a video or anything that shows how to take a list box selection, then assign that list box selection to a variable that can be used? I am probably on my 200th video or document... For example, if I select cat from the list box, I want cat to be equal to a variable in the program that I can later use. Thanks.

    • @Codemycom
      @Codemycom  4 года назад

      This video shows you how to do that. 12:31 ish line 26 of the code. Just assign my_listbox.get(ANCHOR) to a variable

    • @vincenzo3292
      @vincenzo3292 4 года назад

      @@Codemycom Thank you, this helps. Saw this video earlier, but I must have missed the connections. Great series btw. Thanks.

  • @RyanDanielG
    @RyanDanielG 3 года назад

    feed the algorithm! great vid

    • @Codemycom
      @Codemycom  3 года назад

      thank you thank you!

  • @profik5000
    @profik5000 4 года назад

    Fantastic. Thanks a lot

  • @premprasad3511
    @premprasad3511 2 года назад

    Suppose I want to put a list of numbers thru the app as user input. How do it do it ? For example say I want to input a list of numbers ( from a sensor for example) and want to press buttons to know max, min, median, etc of that input data. Is there a way to do it?

    • @Codemycom
      @Codemycom  2 года назад +1

      Sure, that's basic functionality...I'd start at the beginning of my tkinter playlist and just watch for a while to learn the basics of tkinter

  • @Kennerdoll
    @Kennerdoll 3 года назад

    How about if I want to add file paths to a file on a list box using a file dialog?

  • @valentinfaro
    @valentinfaro 3 года назад

    nice video

  • @ourstories007
    @ourstories007 3 года назад

    if i select any item from listbox then it can access all selected options data . for ex. i select any .csv file from csv file names listbox then it access all data of .csv file. It is possible or not ?

  • @joshsfox6266
    @joshsfox6266 4 года назад

    Did you ever make a video where you use listboxes with multiple selections? I followed this video and it worked great but once I added selectmode=MULTIPLE, the get ANCHOR doesn't seem to work anymore.

    • @Codemycom
      @Codemycom  4 года назад

      Yeah, I think I did...

    • @joshsfox6266
      @joshsfox6266 4 года назад

      @@Codemycom I've not been able to find it but I found some good info on stackoverflow to fix my issue. Thanks for these videos. They're great. Just about to watch the one about adding Scrollbars to List Boxes.

    • @_-_-_-_-__--_-_-_
      @_-_-_-_-__--_-_-_ 4 года назад

      @@joshsfox6266 what did u do to fix it

  • @lvzodiac3161
    @lvzodiac3161 4 года назад

    Hai sir i would like to ask how to separate the data which is selected from the database and insert into the listbox...
    For me.. It look like
    1 pen 20...
    2 book 30...
    I want to look like...
    Pen,20 or any separation

  • @afridinaseer
    @afridinaseer 4 года назад

    Sir what is the best option(widget) to fetch all business transactions on that widget and print on a proper sequence withouy any irregularities and i want both the cursors i.e x and y? As i tried with l tried list box but annoying alot as there shoud be grids in it. How to make easy this situation if there is any grid widget who supports x and y cursors? Thanks alot

    • @Codemycom
      @Codemycom  4 года назад

      Sorry, I don't know what you mean.

    • @afridinaseer
      @afridinaseer 4 года назад

      @@Codemycom Sir i meant, how it could be possible to fetch all mysql data on a widget which could be easily managed grid wise e.g 00 , 01, 02, 03, and so on like we normally managed on frame or simple normal root windows. But the problem on the normal window or frame , is that we can't use vertical cursor or horizontal cursor in a case if we have hundreds of records. I tried with listbox and cursor but on listbox we can't put data grid wise and therefore we use lots of \t and still its creating problems. can you please tell me how to handle this situation or any other widget which could handles hundreds of records grid wise? thanks

  • @danielramirez1022
    @danielramirez1022 4 года назад

    Hello, have a problem, i need simulate when select one index from an listbox i want to see the same results in other listbox, how can make that?

    • @Codemycom
      @Codemycom  4 года назад

      What's the problem?

    • @danielramirez1022
      @danielramirez1022 4 года назад

      ​@@Codemycom I show a table with four ListBoxes, my problem is that when selecting any item from any listbox I want the others to look as if they are selected "illuminated"

  • @manuneethicholan3536
    @manuneethicholan3536 4 года назад

    hi john i need a GUI like eclipse tool left side panel .. that means if i click a folder it list all the directory in the path and each directory has a files it s also listed seperately

  • @marsoticchannel7207
    @marsoticchannel7207 4 года назад

    How to enter data from barcode scanner into listbox?

  • @Svendzeen
    @Svendzeen 3 года назад

    Is there a way to reverse the listbox so when an item gets added its added to the bottom of it? and then gets pushed upwards for every new item added. If that makes sense. :)
    Like this:
    First:
    ________
    Item 1
    ________
    Then:
    ________
    Item 1
    Item 2
    Item 3
    ________

    • @paulblart4551
      @paulblart4551 3 года назад +1

      yes. my_listbox.insert(0, 'YOUR ITEM HERE')
      0 is the first slot. All items will go in the first slot, pushing everything else down one.

  • @paweldylon5017
    @paweldylon5017 4 года назад

    I'm getting an error : TypeError: 'str' object cannot be interpreted as an integer. My list consists of strings. I tried END and "end" but still the same error. Any idea why ?

    • @Codemycom
      @Codemycom  4 года назад

      what are you trying to use as an integer?

    • @paweldylon5017
      @paweldylon5017 4 года назад

      @@Codemycom I sorted it out, just a simple typo :) thank you anyways John!

    • @Codemycom
      @Codemycom  4 года назад

      @@paweldylon5017 awesome

  • @newfoundland1956
    @newfoundland1956 2 года назад

    i did the same at work but mine was a dried paint made a mark bleed bad

  • @akramelomrani8728
    @akramelomrani8728 4 года назад

    Me 2 the END doesnt work I experienced it b4 in a past video and i strugled to find the error

  • @szymindor3
    @szymindor3 4 года назад

    thank you sir

  • @annanyadesai1533
    @annanyadesai1533 4 года назад

    while clicking the delete button, it doesn't delete the highlighted item, instead it deletes the item below. Pls help :)
    from tkinter import*
    root=Tk()
    root.title("Listbox")
    root.geometry("400x400")
    #Listbox
    list1=Listbox(root)
    list1.pack(pady=15)
    #add item to listbox
    list1.insert(END,"pink")
    list1.insert(END,"red")
    list1.insert(3,"blue")
    #add list of items
    mylist=["purple","teal","white"]
    for item in mylist:
    list1.insert(END,item)
    def delete():
    list1.delete(ANCHOR)
    mybutton=Button(root,text="delete",command=delete)
    mybutton.pack(pady=10)

    root.mainloop()

  • @rrrr-kg3wl
    @rrrr-kg3wl 2 года назад

    Could anyone pls tell how to check the background colour of an item
    in a listbox

  • @adamfatyga7977
    @adamfatyga7977 3 года назад

    I cant find list box but from opening menu.

  • @supersonic6734
    @supersonic6734 4 года назад

    as you said at the beginning, I smashed the like button with a hammer.. my screen got destroyed. Now can't see any thing

  • @generalpinochet9821
    @generalpinochet9821 4 года назад

    i got this error:AttributeError: 'NoneType' object has no attribute 'delete',pls help

    • @Codemycom
      @Codemycom  4 года назад

      Do you have a typo in your code?

    • @generalpinochet9821
      @generalpinochet9821 4 года назад

      @@Codemycom i checked and yeah, i had one. Thanks for helping me.

  • @MD-cu8tt
    @MD-cu8tt 4 года назад

    Brother I wish if you do a tutorial for building e-commerce website using Django and saleor.io or you suggest another method for building e-commerce website using Django. I personally do not like Wordpress

    • @Codemycom
      @Codemycom  4 года назад

      I may do an e-commerce site sometime..

    • @MD-cu8tt
      @MD-cu8tt 4 года назад

      Codemy.com thank you

  • @vanshatcode
    @vanshatcode 4 года назад

    Thanks

  • @amirmohammadk745
    @amirmohammadk745 3 года назад

    i dont have listbox.insert

    • @Codemycom
      @Codemycom  3 года назад

      of course you do.

    • @amirmohammadk745
      @amirmohammadk745 3 года назад

      hmmmm

    • @Codemycom
      @Codemycom  3 года назад

      @@amirmohammadk745 You likely typed something wrong in your code

    • @amirmohammadk745
      @amirmohammadk745 3 года назад

      @@Codemycom maybe

    • @Codemycom
      @Codemycom  3 года назад

      @@amirmohammadk745 there's no maybe about it.

  • @rajmaddheshiya3025
    @rajmaddheshiya3025 4 года назад +1

    Sir can make video for CBSE class 12

  • @scullyy
    @scullyy Год назад

    END only works if you import *
    Otherwise you will have to specify module name, like tkinter.END or tk.END

    • @Codemycom
      @Codemycom  Год назад

      Yeah, that's why we import * at the top of the code...

    • @scullyy
      @scullyy Год назад

      I think my comments are being deleted as spam because I'm replying to someone with an URL as a name lol. May want to look into that. Anyway, it was a response to 5:36. It has nothing to do with operating system

    • @Codemycom
      @Codemycom  Год назад

      @@scullyy No, you're mistaken. Nothing gets deleted. If it's spam, it gets flagged as spam and I have to approve it. That has not happened.

    • @langeNOR
      @langeNOR Год назад +1

      I can confirm comments I make with @Codemy**** in them gets flagged as spam

    • @Codemycom
      @Codemycom  Год назад

      @@langeNOR Comments that get flagged as spam are sent to me for approval. They don't just disappear. And I'm not getting any from you.

  • @froehmaj
    @froehmaj 4 года назад

    thx

  • @antonypace8907
    @antonypace8907 9 месяцев назад

    Why global?

    • @Codemycom
      @Codemycom  9 месяцев назад

      why not

    • @antonypace8907
      @antonypace8907 8 месяцев назад

      @@Codemycom You typed the keyword global for my_label and I'm trying to learn Python. I don't understand why you typed the word global. I think it would work just the same without the keyword global so I asked why you typed it. I haven't learnt a lot from your reply.

  • @FatlessMidget
    @FatlessMidget 2 года назад

    Walter White teaching code ? unreal !