
Ok let's dive in to the project. and this is my first post hear so you know what I'm talking about. Main libraries I use are the FTPlib and customtinter for the GUI.
Source code :
ukihunter / Python-FTP-Client
A simple and efficient FTP client built with Python, allowing users to connect to FTP servers, upload/download files, and manage directories seamlessly.
Making the GUI
First i created the GUI using Figma.and i used a tool called Tkinter-Designer to import them to the python Gui it is a very easy way to make python GUI but it has some downfalls.
Tkinter-Designer :
https://github.com/ParthJadhav/Tkinter-Designer
Video Tutorial :
https://www.youtube.com/watch?v=oLxFqpUbaAE&t=562s
Documentation :
https://github.com/ParthJadhav/TkinterDesigner/blob/master/docs/instructions.md
After creating the GUI you can go to the next step 🤓
Cording
Requirements :
# This project uses Python's standard libraries only.# No additional packages need to be installed.# Optional: Specify Python version if needed# python_version >= 3.9
Now we have to import the libraries that we used for this project.
import os # For operating system/file handlingfrom pathlib import Path # For path manipulationfrom ftplib import FTP # For FTP protocol operationsimport datetime # For timestamp handlingfrom tkinter import ttk, messagebox # GUI componentsimport tkinter as tkfrom tkinter import Tk, Canvas, Entry, Text, Button, PhotoImage
These are the Generated by the Tkinter-Designer and you don't have to worry about that
# Set up paths for GUI assetsOUTPUT_PATH = Path(__file__).parentASSETS_PATH = OUTPUT_PATH / Path(r"C:\Users\GIGABYTE\Desktop\New folder (4)\build\build\assets\frame0")def relative_to_assets(path: str) -> Path: """Helper function to create absolute paths for GUI assets""" return ASSETS_PATH / Path(path)
Basic GUI model
# Create main application windowwindow = Tk()window.title("FTP client By uki")window.geometry("1280x720")window.configure(bg="#2B2B2B") # Dark background color
Defining the Default file path to the client
# Global variables for FTP connection and navigationftp = None # Will hold the FTP connection objectcurrent_ftp_path = "/" # Current directory on FTP servercurrent_local_path = "D:/" # Current directory on local machine
issue : I used the default
"D:/"
because if you put this in toC:/
it will return with access denied error.
Now we going to received the files from the local machine in hear i used the Tree view to show case the files it also usetry
function to update the file list .in the end as you can see it has Error handling and toPermission Error
andException
This part in the code handle the navigation in the local machine decretory using Double click function.
Nowlocal_go_back
function handle the back navigation in the local machine directory.
Now it take the inputhost
username
password
and it usetry
function to establish the connection to the server. if the connection successful it return the log as✅ Connected successfully!
if not it return theException
Error
Now List down the Host files as same as local machine and also error handling
Handling the file navigation in the Host :
Host and local file Tree view stretcher :
loading the decretory when loading(in this case it DriveD:/
)
Button stretcher and function calling :
This Button is the tiger that to connect to the ftp server
command=connect_to_ftp,
other variables are the design and the position of the button
This Button is the tiger that to delete selected file from the ftp server
command=delete_file,
other variables are the design and the position of the button
This Button is the tiger that to Upload selected file from the local client
command=upload_file,
other variables are the design and the position of the button
This Button is the tiger that to Download selected file from the Host Server
command=download_file,
other variables are the design and the position of the button
Main function in the Ftp client
when the
download_file
function tiger it check the connection and try to dowanlad the selcted file from the host if not it return error massages usingmessagebox
if all good it save the file to the local path.
This function also have the same procedure except it upload file to the host and also provide necessary error massages.
Function that delete file from the host this can't be perform in the local machine.
Path verification
Upload log
logging the uploading success This Enter the text to entry_4*Download log *
logging the Downloading success. This Enter the text to entry_4
Ok now you know how it happened. I know this can be a real boring one for you .maybe not.However this is my first article you can wish me luck 😉
Top comments(0)
For further actions, you may consider blocking this person and/orreporting abuse