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.
๐๐ Python FTP Client
A powerful yet simple FTP client built with Python, allowing seamless file transfers between local and remote servers. Perfect for managing FTP connections with ease!
๐ฏ Key Features
โ๏ธ Connect to any FTP server securely
๐ Upload & Download files effortlessly
๐ Manage Directories (list, rename, delete)
๐ Transfer Status Updates in real-time
๐ Secure & User-Friendly
๐ง Installation
1๏ธโฃ Clone the Repository
git clone https://github.com/Ukihanter/Python-FTP-Client/tree/main
cd your-repo-name
2๏ธโฃ Install Dependencies
pip install -r requirements.txt
๐ How to Use
โก Run the FTP Client:
python gui.py
๐ก Enter FTP server details and start transferring files easily!
๐ฆ Requirements
๐น Python 3.x
๐น ftplib
(Built-in)
๐น Any additional dependencies in requirements.txt
๐น Defult local path is set to D:\ Feel free to edit it.
๐ License
๐ Open-source under the MIT License โ Feel free to contribute!
๐ Contribute & Star โญ the project if you findโฆ
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 handling
from pathlib import Path # For path manipulation
from ftplib import FTP # For FTP protocol operations
import datetime # For timestamp handling
from tkinter import ttk, messagebox # GUI components
import tkinter as tk
from 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 assets
OUTPUT_PATH = Path(__file__).parent
ASSETS_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 window
window = 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 navigation
ftp = None # Will hold the FTP connection object
current_ftp_path = "/" # Current directory on FTP server
current_local_path = "D:/" # Current directory on local machine
issue : I used the default
"D:/"
because if you put this in to
C:/
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 use try
function to update the file list .in the end as you can see it has Error handling and to Permission Error
and Exception
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 input host
username
password
and it use try
function to establish the connection to the server. if the connection successful it return the log as โ
Connected successfully!
if not it return the Exception
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)