When run standalone, the “popup” button of script in Example 10-10 creates the input
form shown in Figure 10-6; this is also what we get when its main function is launched
by the mytools.py shell tools GUI. Users may either type input and output filenames
into the entry fields or press the “browse” buttons to pop up standard file selection
dialogs. They can also enter filename patterns—the manual glob call in this script ex-
pands filename patterns to match names and filters out nonexistent input filenames.
Again, the Unix command line does this pattern expansion automatically when running
the packer from a shell, but Windows does not.
Figure 10-6. The packdlg input form
When the form is filled in and submitted with its OK button, parameters are finally
passed along to the main function of the non-GUI packer script listed earlier to perform
file concatenations.
The GUI interface to the unpacking script is simpler because there is only one input
field—the name of the packed file to scan. We also get to reuse the form row builder
module developed for the packer’s dialog, because this task is so similar. The script in
Example 10-11 (and its main function run by the mytools.py shell tool GUI’s selections)
generates the input form window shown in Figure 10-7.
Figure 10-7. The unpkdlg input form
Example 10-11. PP4E\Gui\ShellGui\unpkdlg.py
popup a GUI dialog for unpacker script arguments, and run it
from tkinter import * # widget classes
from unpacker import unpack # use unpack script/module
from formrows import makeFormRow # form fields builder
def unpackDialog():
ShellGui: GUIs for Command-Line Tools | 621