Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Python 2.7 Tkinter and ftplib
- # Import the FTP object from ftplib
- from ftplib import FTP
- from Tkinter import *
- app = Tk()
- app.title("FTP")
- app.geometry("300x500")
- def handleDownload(block):
- file.write(block)
- print ".",
- def login():
- ftp.login(username.get(),password.get())
- # This is where I am held up I tried ftp.retrlines('LIST') but it would
- # not be inserted into to the list box instead it inserted "Tranfer Complete" at the end!
- # Any suggetion?
- h = ?
- stuff = Listbox(app)
- stuff.insert(END, h)
- stuff.pack()
- filename = "Steam Engine Poster.pdf"
- Label(app, text ='Opening local file ' + filename).pack()
- file = open(filename, 'wb')
- Label(app, text = "Downloading Steam Engine Poster.pdf").pack()
- ftp.retrbinary('RETR ' + filename, handleDownload)
- Label(app, text = "Closing FTP connection!").pack()
- ftp.close()
- ftp = FTP('sciphigames.com')
- Label(app, text = "Login").pack()
- username = StringVar(None)
- username = Entry(app, text = "Username: ")
- username.pack()
- password = StringVar(None)
- password = Entry(app, text = "Password: ")
- password.pack()
- button = Button(app, text = "Login!", command = login)
- button.pack()
- app.mainloop()
- lines = []
- def append_line(line):
- lines.append(line)
- ftp.retrlines('LIST', append_line)
Add Comment
Please, Sign In to add comment