Demos are fun, but to better show how things like the
GuiMixin class can be of practical use, we
need a more realistic application. Here’s one: suppose you’ve written
a set of command-line system administration scripts, along the lines
of those we studied in Part II. As we
saw, such scripts work well from a command line, but require you to
remember all their options each time they are run; if you’re like me,
this usually implies having to pore over the source code after a
period of nonuse.
Instead of requiring users of such tools (including yourself) to type cryptic commands at a shell, why not also provide an easy-to-use tkinter GUI interface for running such programs? Such a GUI can prompt for command-line inputs, instead of expecting users to remember them. While we’re at it, why not generalize the whole notion of running command-line tools from a GUI, to make it easy to support future tools too?
Examples 10-5 through 10-11—seven files, spanning two command-line scripts, one GUI utility module, two GUI dialogs, and a main GUI and its options specification module—comprise a concrete implementation of these artificially rhetorical musings. Because I want this to be a general-purpose tool that can run any command-line program, its design is factored into modules that become more application-specific as we go lower in the software hierarchy. At the top, things are about as generic as they can be, as shown in Example 10-5 ...