User Form: Select Start Point
Get the journey started by building graphical user interfaces for the TSP application to empower users to choose their starting point with ease.
We'll cover the following
User-friendly search masks are almost indispensable in today’s flood of data. Even though there might only be 13 stores to choose from, experience has shown that our colleagues at the burger chain we work for can come up with all sorts of creative names for them, which can make it difficult to find the right one. For example, instead of simply using the search term “StoreA,” users might use “store A,” “store alpha,” or “the first store,” among other possibilities. This is a common problem related to
Input form
The tkinter
library in Python provides a toolkit for building tkinter
library provides a variety of widgets, such as buttons, labels, menus, text boxes, and canvases, which can be used to create interactive and responsive GUIs.
A user form needs an entry box for the user’s search input. We create a window that consists of a Label
and an Entry
box. We also create a Listbox
that outputs the matching search hits.
The main functionality consists of three functions:
listFill()
: This clears the contents of theListbox
and fills it with new data provided as an argument. As the user types,listBoxTerms
is updated with the terms that match the user’s input.listBoxTermsDoubleClick()
: This deletes the text in the search box and inserts the selected item from theListbox
. It also prints the selected item to the console.listFillFilter()
: This updates theListbox
with items that match the user’s search text.
The complete code looks like this:
Get hands-on with 1400+ tech skills courses.