Search code examples
pythontkinterftplib

Ftplib getting command return value


I'm making an FTP client with Tkinter and when I try to list files/directories, it prints it to the console, and it only puts 226 Transfer complete. inside of my textbox. (Instead of putting the files in my textbox)

I've tried to do this:

files = self.ftp.retrlines('LIST')
self.targetFiles.config(state=tk.NORMAL)
self.targetFiles.delete('1.0', tk.END)
self.targetFiles.insert(tk.END, files)
self.targetFiles.config(state=tk.DISABLED)

But It just prints to the console.

Expected: Returns to the variable, using the variable to put in a textbox.


Solution

  • SOLVED! What you need to do is replace the command ftp.retrlines('LIST') with the command ftp.nlst() -> what retrlines does is simply outputs the current command, and nlst stores the return into your variable (majorly simplified)