A simple Python chat client featuring a Tkinter GUI. The program utilizes asynchronous processing to simultaneously read network messages, send user input, save history to a file, and monitor connection stability - all within a single window.
- Operating System: Linux, macOS, or Windows
- Language:
Python 3.11+ - Asynchronous Framework:
asyncio&anyio - Asynchronous File Handling:
aiofiles - Configuration:
pydantic-settings&pydantic - Graphical Interface:
tkinter
.
├── logs/ # Dynamically generated application logs folder
├── .env.example # Example environment configuration
├── chat.history # Dynamically generated persistent chat history log
├── token.json # Dynamically generated JSON file storing user credentials
├── config.py # Unified Pydantic application configuration & validators
├── logging_config.py # Non-blocking async queue logger
├── gui.py # Tkinter layout definition and async UI update loops
├── reader.py # Network stream consumer and storage workers
├── registration.py # Standalone graphical user registration wizard
├── sender.py # Network stream authorization and keep-alive workers
├── main.py # Central network orchestrator and application entry point
└── requirements.txt # Python dependencies
git clone https://github.com/...
cd project-directorypython -m venv venv
venv\Scripts\activate # on Windows
source venv/bin/activate # on Linux / macOSpip install -r requirements.txtCreate a .env file in the root directory based on .env.example:
# Server
SERVER_HOST=127.0.0.1
READ_PORT=5000
SEND_PORT=5050
# Logging
LOG_LEVEL=INFO
# Chat Client
HISTORY_FILE=chat.history
TOKEN_FILE=token.json
ACCOUNT_HASH="your_account_hash"Before chatting, new users must obtain a secure authorization token from the server. Run the standalone graphical registration wizard:
python registration.pyOnce your token is generated, start the main application:
python main.pyThe client supports dynamic configuration override via command-line arguments using the integrated Pydantic CLI
engine. Arguments provided via the terminal have the highest priority and will automatically override values defined in
the .env file.
You can view the help menu and available options by running:
python registration.py --help
# or
python main.py --help# Override token resolution paths directly from the shell
python registration.py --token custom_file.json
python main.py --token custom_file.json
# Run the client and save the chat history to a custom file named "chat.txt"
python main.py --history chat.txt
# Connect to a specific remote server at "host.com" using custom ports
python main.py --host host.com --r-port 5000 --s-port 5050
# Login with an existing token using the --hash flag
python main.py --hash your_account_hash