Created
April 19, 2019 19:12
-
-
Save jsignell/85ab58e74612149ad81ea021a7109cf1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import panel as pn | |
pn.extension() | |
labels = [t[0] + t[1] + t[2] for t in zip('abcdefghijklmnopqrstuvwxyz','bcdefghijklmnopqrstuvwxyza', 'cdefghijklmnopqrstuvwxyzab')] | |
options = dict(zip(labels, range(len(labels)))) | |
multi = pn.widgets.MultiSelect(options=options) | |
sort = pn.widgets.Button(name='▼', width=40) | |
filt = pn.widgets.AutocompleteInput(options=list(options.keys()), placeholder='Filter') | |
def sort_options(event): | |
reverse = not event.new % 2 | |
multi.options = {k: multi.options[k] for k in sorted(multi.options.keys(), reverse=reverse)} | |
multi.param.trigger('options') | |
sort.name = '▼' if not reverse else '▲' | |
def filter_values(event): | |
multi.value = [v for k,v in multi.options.items() if event.new in k] | |
sort.param.watch(sort_options, 'clicks') | |
filt.param.watch(filter_values, 'value') | |
result = pn.pane.Str() | |
multi.link(result, value='object') | |
pn.Column(pn.Row(sort, filt, margin=0), multi, result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment