Skip to Content
Python GUI Programming with Tkinter
book

Python GUI Programming with Tkinter

by Alan D. Moore
May 2018
Beginner to intermediate content levelBeginner to intermediate
452 pages
11h 26m
English
Packt Publishing
Content preview from Python GUI Programming with Tkinter

Implementing the FTP upload function

Now that the test server is up and running, let's build our FTP upload function and the logic for the GUI. While the standard library doesn't contain an FTP server library, it does contain an FTP client library in the form of the ftplib module.

Begin by importing ftplib into our network.py file:

import ftplib as ftp

An FTP session can be created using the ftplib.FTP class. Because this is a stateful session, it needs to be closed after we're done; to make sure we do this, FTP can be used as a context manager.

Let's start our function by connecting to the FTP server:

def upload_to_corporate_ftp( filepath, ftp_host, ftp_port, ftp_user, ftp_pass): with ftp.FTP() as ftp_cx: ftp_cx.connect(ftp_host, ftp_port) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python GUI Programming with Tkinter - Second Edition

Python GUI Programming with Tkinter - Second Edition

Alan D. Moore

Publisher Resources

ISBN: 9781788835886Supplemental Content