DEV Community

Cover image for Ftp client with GUI Python๐Ÿฑโ€๐Ÿ
Uki
Uki

Posted on

Ftp client with GUI Python๐Ÿฑโ€๐Ÿ

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 :

GitHub logo 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!

forest

๐ŸŽฏ 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  
Enter fullscreen mode Exit fullscreen mode

2๏ธโƒฃ Install Dependencies

pip install -r requirements.txt  
Enter fullscreen mode Exit fullscreen mode

๐Ÿš€ How to Use

โšก Run the FTP Client:

python gui.py  
Enter fullscreen mode Exit fullscreen mode

๐Ÿ’ก 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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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

File receiving

This part in the code handle the navigation in the local machine decretory using Double click function.

Navigation in local machine

Nowlocal_go_back function handle the back navigation in the local machine directory.
GO back function

Now it take the input hostusernamepassword 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
Stablish the connection to server

Now List down the Host files as same as local machine and also error handling

List down the Host files

Handling the file navigation in the Host :
navigation in the Host

Host and local file Tree view stretcher :
local file

Host file

loading the decretory when loading(in this case it DriveD:/)

Image description

Button stretcher and function calling :

Connecting button

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

Delete Button
Delete 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

Upload Button
Upload 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

Download Button
Download 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

Download function
Download function

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 using messagebox if all good it save the file to the local path.

Upload function
Upload function

This function also have the same procedure except it upload file to the host and also provide necessary error massages.

Deleting function
Deleting function

Function that delete file from the host this can't be perform in the local machine.

Path verification

Upload log
Upload path
logging the uploading success This Enter the text to entry_4

*Download log *
Download path
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)