This is a simple GUI application to encode text to Morse code using Python and Tkinter.
- Encode text input to Morse code
- Display encoded Morse code
- Handles letters, numbers, punctuation and special characters
- Simple Tkinter GUI with entry field and encode button
The code consists of:
MORSE_CODE_DICT
- Dictionary mapping characters to Morse codeconvert_to_morse()
- Function to encode text to Morse code- Tkinter GUI code - Simple input field, button and result label
The MORSE_CODE_DICT
contains the mapping from characters to Morse code sequences. It supports letters, numbers, punctuation and some special Spanish characters.
The convert_to_morse()
function takes the input text, loops through each character, looks up the Morse code in the dictionary and concatenates them into a string separated by spaces.
The Tkinter GUI is made up of:
msg_label
andmsg_entry
for the text input fieldencode_btn
button to trigger encodingoutput_label
to display the encoded Morse code
The encode()
function is called when the encode button is clicked. It takes the text, converts to Morse code using convert_to_morse()
and updates the output_label
.
Run the Python file and enter text in the input field. Click the "Codificar" button to encode the text to Morse code. The output will be displayed below.
Requires Python 3 and Tkinter.
pip install tkinter