Multi-interface Morse translator (CLI, API, GUI)
Project description
Morse-Translator
نسخه فارسی سند النسخة العربية من المستند Version française du document
A compact, feature-rich Morse Code ⇄ Text translator with CLI, GUI, and REST API. Bidirectional conversions for letters, numbers, and common punctuation with built-in validation.
📸 Screenshots
🚀 Features
- Text ↔ Morse: bidirectional conversion for A–Z, 0–9, and common punctuation
- Validation: checks Morse syntax (allowed:
.,-,/, space; max 6 chars per token) - Interactive CLI: menu-driven experience via
main.py - Desktop GUI: responsive
customtkinter-based UI with text/Morse input fields and toggle switch - REST API: FastAPI with versioned routes (
/v1) and interactive docs at/docs - Installable package: global
morsecommand afterpip install -e . - CLI flags: single-shot conversions (
-t,-m,-vm,-ui)
📦 Installation
- Clone and create virtual environment:
git clone https://github.com/amirhossein77-98/Morse-Translator.git
cd Morse-Translator
python3 -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
- Install dependencies:
pip install -e .
Installs the project in development mode with the global morse CLI entry point.
Alternative environments:
- pipenv:
pipenv install --dev && pipenv shell - poetry:
poetry install && poetry shell - uv:
uv sync(if initialized with uv)
🖥 Usage
Direct run
Interactive menu:
python3 main.py
CLI args
All flags are mutually exclusive. Use / (space-slash-space) to separate words in Morse.
Text to Morse:
python3 main.py -t "Hello World"
morse -t "Hello World" # After pip install -e .
Morse to Text:
python3 main.py -m ".... . .-.. .-.. --- / .-- --- .-. .-.. -.."
Validate Morse:
python3 main.py -vm ".... . .-.. .-.. ---"
GUI
Launch the responsive customtkinter GUI:
python3 main.py -ui
morse -ui # After pip install -e .
Features:
- Toggle between "Text to Morse" and "Morse to Text" via switch
- Real-time input/output textboxes
- Validation for Morse input
- Responsive grid layout, centered widgets
API
Start the FastAPI server:
uvicorn api.app:app --reload
Open http://127.0.0.1:8000/docs for interactive API docs.
Example endpoints (base: /v1):
# GET
curl "http://127.0.0.1:8000/v1/text-to-morse/hello"
curl "http://127.0.0.1:8000/v1/morse-to-text/--"
curl "http://127.0.0.1:8000/v1/validate-morse/--"
# POST
curl -X POST "http://127.0.0.1:8000/v1/text-to-morse" \
-H "Content-Type: application/json" \
-d '{"text":"hello"}'
Response format:
{
"original_text": "hello",
"translated_text": ".... . .-.. .-.. ---"
}
Installable morse package
After pip install -e ., use the global morse command:
morse -t "Hello"
morse -m ".... . .-.. .-.. ---"
morse -vm "..."
morse -ui
🔧 Testing
Run unit and API tests (no server startup needed):
python3 -m unittest discover -v # All tests
python3 -m unittest test.api_tests # API only
python3 -m unittest test.converter_tests # Converter only
Note: Tests use unittest and FastAPI TestClient. Ensure no stray Unicode characters in test strings.
🛠 Packaging & Contributing
Build distribution packages:
pip install build
python -m build
Creates wheels and source distributions in dist/.
Project structure:
core/converters.py— conversion logic & validationdata/morse_dataset.py— Morse/ASCII mappingapi/app.py— FastAPI applicationapi/routes/v1.py— versioned endpointsviews/ui/ctkinter_ui.py— GUI withcustomtkintertest/— unit and API tests
Contributing: Bug reports and PRs welcome. Please include repro steps and test cases.
📜 License
MIT License — see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file amirstein_morse_translator-0.3.1.tar.gz.
File metadata
- Download URL: amirstein_morse_translator-0.3.1.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb81e96f6fb4805077751a3b5823fbb1b55add99c9ac28b198d62f9386b55f91
|
|
| MD5 |
6ca4e39b225e7de2d1b23bdde66e1e96
|
|
| BLAKE2b-256 |
3069047ad9914f6fef397e7b87d25836c7b39e5049d6c01baaf05120ea5b5195
|
File details
Details for the file amirstein_morse_translator-0.3.1-py3-none-any.whl.
File metadata
- Download URL: amirstein_morse_translator-0.3.1-py3-none-any.whl
- Upload date:
- Size: 18.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
339f000567b99375eecfdb6b229a4d5e8fd926032e7364fc14a4fe2badc5f6b1
|
|
| MD5 |
a0f91e810650ea6108fd6eb186050b56
|
|
| BLAKE2b-256 |
ef221e137fdf1b8ac3705a911444ee2265e4d5c110c48ed33b29343ceac6ab0d
|