mirror of https://github.com/chriskiehl/Gooey.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.3 KiB
1.3 KiB
Customizing FilterableDropdown's search behavior
Out of the box, FilterableDropdown does a very simple 'startswith' style lookup to find candidates which match the user's input. However, this behavior can be customized using GooeyOptions to support all kinds of filtering strategies.
For each example, we'll be starting with the following sample program. This uses just 4 choices to keep the different options easy to follow. However, FilterableDropdown
is fully virtualized and can be used with 10s of thousands of choices.
from gooey import Gooey, GooeyParser, PrefixTokenizers
choices = [
'Afghanistan Kabul',
'Albania Tirana',
'Japan Kyoto',
'Japan Tokyo'
]
@Gooey(program_name='FilterableDropdown Demo', poll_external_updates=True)
def main():
parser = GooeyParser(description="Example of the Filterable Dropdown")
parser.add_argument(
"-a",
"--myargument",
metavar='Country',
help='Search for a country',
choices=choices,
widget='FilterableDropdown',
gooey_options={
'label_color': (255, 100, 100),
'placeholder': 'Start typing to view suggestions'
})
args = parser.parse_args()
print(args)