How to Display selected values from a dictionary to a listbox

MOHAMMED ISMAIL

I'm busy making a program with a search function where a person will enter for example subject "Information Systems" in a GUI Tk entry, and i want it to display on those records which has Information systems. Here is some code:

StudentList[[Tom,Information systems],[John,Computers]]

So basically if I type Information systems, it must show in my listbox: "Tom, Information Systems"

How do i make this search function work? This is what i have tried

for i in students:
    if viewcode == True:
        lb1.insert(END,str(i))
scotty3785

This does roughly what you are looking for. Enter your search term in the Entry box and press Return. It will then populate the Listbox with any matching entries from the student list.

from tkinter import *

student_list = [['Tom','Information Systems'],['John','Computers']]


class App(Frame):
    def __init__(self,parent=None,**kw):
        Frame.__init__(self,master=parent,**kw)
        self.searchValue = StringVar()

        self.searchBox = Entry(self,textvariable=self.searchValue)
        self.searchBox.pack()
        self.resultList = Listbox(self)
        self.resultList.pack()

        self.searchBox.bind('<Return>',self.update)

    def update(self,e):
        print("*")
        self.resultList.delete(0,END)
        searchkey = self.searchValue.get()
        for student in student_list:
            if searchkey == student[0]:
                self.resultList.insert(END,str(student))
            elif searchkey == student[1]:
                self.resultList.insert(END,str(student))

if __name__ == '__main__':
    root = Tk()
    app = App(root)
    app.pack()
    root.mainloop()

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How to show the numeric position from a selected item in a listbox in a label

From Dev

How to display unicoded dictionary values

From Dev

Shiny - read values from listbox when multiple values selected

From Dev

Visual Basic: How can I get all selected Values from a Listbox (Selectionmode Multisimple) using a Loop?

From Dev

MVC ListBox Selected Values

From Dev

Get a List of the Selected Values in a ListBox

From Dev

How to remove selected item from ListBox in windwos phone 8.1 Silverlight

From Dev

How to display selected checkboxes' values in select dropdown?

From Dev

How to join values from dictionary?

From Dev

how to display value in listbox from dataview

From Dev

How can I search matching values or items selected from a useform multiselect listbox from a sheet?

From Dev

How to get multiple selected values from listbox C# Windows Application

From Dev

How to get ALL selected items from ListBox into an EditBox?

From Dev

how to delete from selected items of listbox in asp.net

From Dev

How to extract values from the button in listbox?

From Dev

how to display data from webservice in listbox

From Dev

How to show data from selected item in listbox wpf using mvvm?

From Dev

Adding all values selected from the Listbox

From Dev

adding values to listbox from the drop down selected item

From Dev

How to display values in a dictionary?

From Dev

Getting the Un-selected values from the listbox

From Dev

Selected items from listbox

From Dev

How to display selected checkboxes' values in select dropdown?

From Dev

How to output only a part of values from ListBox?

From Dev

Binding Dictionary<String, Int32> by keys to ListBox and selected item values to ComboBox

From Dev

How to get listbox to display values C#

From Dev

How to get an image to display in Picturbox from a Listbox selected item

From Dev

Pass Selected values of ListBox to Controller

From Dev

How to display selected numeric values in a comboBox

Related Related

  1. 1

    How to show the numeric position from a selected item in a listbox in a label

  2. 2

    How to display unicoded dictionary values

  3. 3

    Shiny - read values from listbox when multiple values selected

  4. 4

    Visual Basic: How can I get all selected Values from a Listbox (Selectionmode Multisimple) using a Loop?

  5. 5

    MVC ListBox Selected Values

  6. 6

    Get a List of the Selected Values in a ListBox

  7. 7

    How to remove selected item from ListBox in windwos phone 8.1 Silverlight

  8. 8

    How to display selected checkboxes' values in select dropdown?

  9. 9

    How to join values from dictionary?

  10. 10

    how to display value in listbox from dataview

  11. 11

    How can I search matching values or items selected from a useform multiselect listbox from a sheet?

  12. 12

    How to get multiple selected values from listbox C# Windows Application

  13. 13

    How to get ALL selected items from ListBox into an EditBox?

  14. 14

    how to delete from selected items of listbox in asp.net

  15. 15

    How to extract values from the button in listbox?

  16. 16

    how to display data from webservice in listbox

  17. 17

    How to show data from selected item in listbox wpf using mvvm?

  18. 18

    Adding all values selected from the Listbox

  19. 19

    adding values to listbox from the drop down selected item

  20. 20

    How to display values in a dictionary?

  21. 21

    Getting the Un-selected values from the listbox

  22. 22

    Selected items from listbox

  23. 23

    How to display selected checkboxes' values in select dropdown?

  24. 24

    How to output only a part of values from ListBox?

  25. 25

    Binding Dictionary<String, Int32> by keys to ListBox and selected item values to ComboBox

  26. 26

    How to get listbox to display values C#

  27. 27

    How to get an image to display in Picturbox from a Listbox selected item

  28. 28

    Pass Selected values of ListBox to Controller

  29. 29

    How to display selected numeric values in a comboBox

HotTag

Archive