If you flip back to the end of the preceding chapter, you’ll find that this version is similar
in structure to its counterpart there; in fact, it has the same name (and is distinct only
because it lives in a different directory). The class here, though, knows how to use the
FTP-based getfile module from earlier in this chapter instead of the socket-based
getfile module we met a chapter ago. When run, this version also implements more
input fields, as in Figure 13-2, shown on Windows 7.
Figure 13-2. FTP getfile input form
Notice that a full absolute file path can be entered for the local directory here. If not,
the script assumes the current working directory, which changes after each download
and can vary depending on where the GUI is launched (e.g., the current directory differs
when this script is run by the PyDemos program at the top of the examples tree). When
we click this GUI’s Submit button (or press the Enter key), the script simply passes the
form’s input field values as arguments to the getfile.getfile FTP utility function of
Example 13-4 earlier in this section. It also posts a pop up to tell us the download has
begun (Figure 13-3).
Figure 13-3. FTP getfile info pop up
Transferring Files with ftplib | 869