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.

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 data qualityData quality refers to the degree to which data is accurate, complete, reliable, timely, relevant, and consistent with its intended purpose. High-quality data is essential for making informed decisions, performing effective analysis, and achieving business goals.. To prevent these kinds of errors, we’ll include a user-friendly form that will make it easier for our colleagues to select the correct store. This reduces the possibility of incorrect entries and also facilitates usability.

Input form

The tkinter library in Python provides a toolkit for building graphical user interfaces (GUIs)A graphical user interface (GUI) is a type of user interface that allows users to interact with software through visual elements such as icons, buttons, menus, and windows.. It’s a wrapper around the Tcl/Tk GUI toolkitTcl/Tk is a cross-platform graphical user interface (GUI) toolkit that was originally developed as a scripting language and toolset for the Unix operating system. It consists of two main components: Tcl, which is a scripting language, and Tk, which is a set of GUI widgets and utilities., which is a popular choice for creating cross-platform GUI applications due to its simplicity and ease of use. The 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 the Listbox 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 the Listbox. It also prints the selected item to the console.

  • listFillFilter(): This updates the Listbox with items that match the user’s search text.

The complete code looks like this:

Get hands-on with 1400+ tech skills courses.