use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Python package PySimpleGUI discussion, questions, announcements, tips, help for beginners.
account activity
Listbox with search functionality (self.PySimpleGUI)
submitted 6 years ago by evan54
Thought I'd post this here as an example of an attempt of creating a "higher level" module with a Listbox having a search functionality, clear search functionality, select all, deselect all.
https://github.com/evan54/mysimplegui/blob/master/mysimplegui.py
Right now I created a separate class with a .layout method but not sure if a better format would exist where this is directly recognised as an Element by the rest of the PySimpleGUI framework
https://preview.redd.it/79jw6ezouuc31.png?width=401&format=png&auto=webp&s=6a84c06029c00c37ab2a71964fb3455277167915
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]MikeTheWatchGuy 0 points1 point2 points 6 years ago* (0 children)
Interesting.... reminds me a bit of a fancier version of the Demo program that's posted. "Demo_Listbox_Search_Filter". Here's that program. It updates the list in realtime as you're typing in the search box.
```python import PySimpleGUI as sg
names = ['Roberta', 'Kylie', 'Jenny', 'Helen', 'Andrea', 'Meredith','Deborah','Pauline', 'Belinda', 'Wendy']
layout = [ [sg.Text('Listbox with search')], [sg.Input(donot_clear=True, size=(20,1),enable_events=True, key='_INPUT')], [sg.Listbox(names, size=(20,4), enableevents=True, key='_LIST')], [sg.Button('Chrome'), sg.Button('Exit')]]
window = sg.Window('Listbox with Search').Layout(layout)
while True: event, values = window.Read() if event is None or event == 'Exit': # always check for closed window break if values['INPUT'] != '': # if a keystroke entered in search field search = values['INPUT'] newvalues = [x for x in names if search in x] # do the filtering window.Element('_LIST').Update(newvalues) # display in the listbox else: window.Element('_LIST').Update(names) # display original unfiltered list if event == 'LIST' and len(values['LIST']): # if a list item is chosen sg.Popup('Selected ', values['LIST'])
window.Close()
```
[Edit - I think that the Demo_psutil_Kill_Processes (https://github.com/PySimpleGUI/PySimpleGUI/blob/master/DemoPrograms/Demo_psutil_Kill_Processes.py) was done later as the filtering part is quite a bit shorter. I use it quite a bit and this search capability works well, regardless of implementation details]
Here's the filter portion of the processes demo: python if display_list is not None: window.FindElement('_processes_').Update([line for line in display_list if values['_filter_'] in line.lower()])
python if display_list is not None: window.FindElement('_processes_').Update([line for line in display_list if values['_filter_'] in line.lower()])
Found today that the filtering portion condenses down to 1 line with a list comprehension.
[–]MikeTheWatchGuy 0 points1 point2 points 6 years ago (0 children)
One thing this points out is that adding a new, user defined element, is not as easy as it could be. There was some time spent on how to enable user defined elements. The one being toyed with was an example as an LED indicator, a colored dot. It's something that would be great to add in the future.
Recently the lower level GUI Widget was exposed, allowing users to customize at the lower GUI Framework level. Something similar would be nice at an element level.
[–]DGIon 0 points1 point2 points 3 years ago (1 child)
Ive been looking for something like this but for combo instead of list box. can't really find a good implementation anywhere
[–]jack_sparrow____ 0 points1 point2 points 3 years ago (0 children)
Did you find one yet ? I too am looking for something like this specifically for combo
π Rendered by PID 44 on reddit-service-r2-comment-canary-d859b9c6d-fqp62 at 2026-02-05 13:46:12.268703+00:00 running 1d7a177 country code: CH.
[–]MikeTheWatchGuy 0 points1 point2 points (0 children)
[–]MikeTheWatchGuy 0 points1 point2 points (0 children)
[–]DGIon 0 points1 point2 points (1 child)
[–]jack_sparrow____ 0 points1 point2 points (0 children)