Warning

 

Close

Confirm Action

Are you sure you wish to do this?

Confirm Cancel
BCM
User Panel

Posted: 7/18/2024 10:04:54 PM EDT
As a side project I am learning to code in Python. I had an idea to create a program that will convert text to morse code.

I decided to implement with pygame, and I'm hitting some walls.

My github is Fireman9143. I published the project, if anyone wants to take a look. The NewPlan file works to wrap text and morse. The learn_morse file is my first attempt that has a typing box but won't wrap. Full info in the readme.md

(I wish we had a coding forum!)

Link Posted: 7/19/2024 2:19:04 AM EDT
[#1]
I am a code monkey. I mainly work in C, C++, Javascript and Java.  I have never been paid to write Python and have no interest in it from the hobby side mostly due to being an old dog and a new trick.

It's a good language for someone to learn professionally as it has been trending towards greater popularity for several years.
Link Posted: 7/19/2024 2:27:44 AM EDT
[#2]
Do what the pros do, ask chatgpt
Link Posted: 7/19/2024 3:11:41 AM EDT
[#3]
Try stack overflow for more helpful  answers. Python is a great way to get introduced to computer programming.
Link Posted: 7/19/2024 7:23:55 AM EDT
[#4]
Discussion ForumsJump to Quoted PostQuote History
Quoted:
Do what the pros do, ask chatgpt
View Quote



I have been getting the parts for an Icom Band decoder for my HF amp and besides some commercial options there is not a lot out there for what I wanted to do. I just used your suggestion and told it what I wanted to do and it just spit out complete instruction and the Arduino code!

OP try this, in fact you may be able to get it to debug the code for you.
Link Posted: 7/19/2024 8:26:47 AM EDT
[#5]
Just took a look on my phone, so not the greatest view.

1) You have a ton of comments. It almost makes the code unreadable.

       #User input variable
       self.user_text = ""
       #import morse dictionary
       self.morse = morse_code

this is an example of what I'm talking about. You have already imported the morse_code library, here you are creating an object for it, so the comments actually add confusion.

Python prides readability over anything.

2) I know Pygame is a popular library, but I'm not as familiar with it, looks like a lot of the stuff you are doing should be in a UI class.

Personally, I would use pyqt, it is my go to for python UIs. Using QT Designer solves a lot of the headache you are doing there.


I am happy to pull your branch and give you some help or show you an alternative way. What you have so far is pretty decent.

Let me get this straight tho, you want an input box where the user types a sentence, words, whatever. Then you take those letters and retrieve the corresponding Morse value, then display that back to the user. Correct?


Link Posted: 7/19/2024 9:26:45 AM EDT
[#6]
Discussion ForumsJump to Quoted PostQuote History
Quoted:
Just took a look on my phone, so not the greatest view.

1) You have a ton of comments. It almost makes the code unreadable.

       #User input variable
       self.user_text = ""
       #import morse dictionary
       self.morse = morse_code

this is an example of what I'm talking about. You have already imported the morse_code library, here you are creating an object for it, so the comments actually add confusion.

Python prides readability over anything.

2) I know Pygame is a popular library, but I'm not as familiar with it, looks like a lot of the stuff you are doing should be in a UI class.

Personally, I would use pyqt, it is my go to for python UIs. Using QT Designer solves a lot of the headache you are doing there.


I am happy to pull your branch and give you some help or show you an alternative way. What you have so far is pretty decent.

Let me get this straight tho, you want an input box where the user types a sentence, words, whatever. Then you take those letters and retrieve the corresponding Morse value, then display that back to the user. Correct?


View Quote


Thanks for looking!

I know the comments are a pain. I'm learning and it was a way to sort code and remind myself what and where. I copied the idea from the Python Crash Course book, and plan to delete the extra explanations when I have it working.

Yes, the eventual goal is to either type text and get morse or input morse and get text. I wanted each morse character to line up under each text character, and figured that could be a spacing fix once I figured out the layout.

Eventually, I want to make some common morse messages and create a game where you type what you hear, then see the comparison. Since I'm doing all this on a Pi, I also thought it would be cool to rig up a paddle for input (I'm still a long way from figuring out that I/O, I think).

ETA: I had tried to use PyQT to make windows for my first attempt at a CS50P final project.  I can't remember what the specific glitch was, but DesignQT wasn't working for me.  I'm willing to shift gears if there's a better vehicle for implementation.
Link Posted: 7/19/2024 9:31:27 AM EDT
[#7]
Discussion ForumsJump to Quoted PostQuote History
Quoted:
I am a code monkey. I mainly work in C, C++, Javascript and Java.  I have never been paid to write Python and have no interest in it from the hobby side mostly due to being an old dog and a new trick.

It's a good language for someone to learn professionally as it has been trending towards greater popularity for several years.
View Quote


The kids are in 4H Lego robotics. The EV3 mindstorm is no longer supported. I've been interested in micropython and the PyBricks module to start expanding robotics design and programming options.

We used CS50X and CS50P to start learning code.  After Python, we're aiming at C++ and Unreal Engine 5. We want to learn about making games, and C/C++ will be useful in incorporating arduino to the robotics controllers.
Link Posted: 7/19/2024 9:34:59 AM EDT
[#8]
Discussion ForumsJump to Quoted PostQuote History
Quoted:
Do what the pros do, ask chatgpt
View Quote



I'll see what I can find.

The youtube coders I watch have discussed AI and coding. They say AI is like a junior programmer that can copy code but doesn't understand code, so prone to mistakes. I think it will be worth trying though. Thanks for the idea
Link Posted: 7/19/2024 9:38:04 AM EDT
[#9]
Discussion ForumsJump to Quoted PostQuote History
Quoted:
Try stack overflow for more helpful  answers. Python is a great way to get introduced to computer programming.
View Quote


Google gives me stack overflow responses. I wanted to sign up and see where I can ask specific questions and it gave me an error. Not sure what's happening. I'll have to follow up.
Link Posted: 7/19/2024 1:26:12 PM EDT
[#10]
Discussion ForumsJump to Quoted PostQuote History
Quoted:
They say AI is like a junior programmer that can copy code but doesn't understand code, so prone to mistakes.
View Quote

They are exactly right. AI can "learn" from public examples that are manually tagged by a person but unless it has an interpreter built into it the code it spits out has a decent chance of being completely incorrect, whether syntactically or functionally. Not to mention obvious code quality issues which lead to poor optimization and security.
Link Posted: 7/19/2024 3:20:43 PM EDT
[#11]
I've used Python in the past and it's a fairly easy language to learn, but there are some rather complex implementations.
For general use in web applications Python's not a bad way to go.
Hobbyists like it and it's widely used to write code for Raspberry Pi and there's even a version for embedded systems called MicroPython.

There's also Golang which is gaining in popularity.
It's more geared towards APIs and microservices and is very C-like but adds things like garbage collection and memory management.

I always find it funny when a newly graduated Software Engineer gets hired and starts trying to stir the pot in having an opinion on which is the best overall programming language.
The older SEs roll their eyes and never engage.
One SE shot back and said: "It doesn't matter, just pick one and get really good at it".
Link Posted: 7/19/2024 3:26:46 PM EDT
[#12]
My 13-year-old thinks Python is pretty cool.

Apparently it’s a common entry level code.
Link Posted: 7/19/2024 3:40:10 PM EDT
[#13]
It looks like a reasonable and fun learning project.  (link to the readme)

There are a decent number of arffolk competent in python, but you might have better luck finding someone who has time to read code and coach you here.
Link Posted: 7/19/2024 4:57:16 PM EDT
[#14]
Discussion ForumsJump to Quoted PostQuote History
Quoted:
It looks like a reasonable and fun learning project.  (link to the readme)

There are a decent number of arffolk competent in python, but you might have better luck finding someone who has time to read code and coach you here.
View Quote



I got a good laugh just now. I NEVER would have clicked on that forum for anything computer related.  Apparently "urban commando" means something other than what I thought!

Thanks for the link. I'll repost over there.

ETA: No one has replied on that forum
Link Posted: 7/25/2024 10:17:09 AM EDT
[#15]
I've made some progress.

The lines wrap more evenly, and scale based on the user screen. Now there's sound effects, so when you type the letter you hear the morse.

Still not happy with the text width. I'm thinking of ways to try to match each letter over the morse code letter. Need some kind of cursor to know where you are. Need to change from play button to words per minute button. Work in progress

@gcw did you get a chance to look it over? github is updated with my new code. If you have ideas on how to implement this in PyQT, I'm interested. BroCode is currently publishing PyQT5 tutorials on youtube.
Link Posted: 7/25/2024 10:34:02 AM EDT
[#16]
Discussion ForumsJump to Quoted PostQuote History
Quoted:
My 13-year-old thinks Python is pretty cool.

Apparently it’s a common entry level code.
View Quote

I write code all day at work.  Python is a big part of some of the projects.
I wouldn't call it entry level.  It can be easy for a beginner to get started, simply because it is an interpreted language with really good standard libraries.  Write a script, run it, no compiler required.  Filesystem access, network, threads, math are all just one "import" statement away.

The oddball syntax (whitespace affects the scope, lolwut) can lead to some bugs that are hard for beginners to track down.
Link Posted: 7/25/2024 12:30:35 PM EDT
[#17]
CW Skimmer

CW Skimmer is a great decoding software for those looking for an off the shelf solution.
Link Posted: 7/25/2024 1:24:36 PM EDT
[#18]
Discussion ForumsJump to Quoted PostQuote History
Quoted:
CW Skimmer

CW Skimmer is a great decoding software for those looking for an off the shelf solution.
View Quote



This looks like it decodes cw received through the radio. I'm a long way from there!

This project goal is to have a tool to learn cw. Type your message, then see and hear the morse. Eventually, input morse, and see the text (maybe hear the text too, I know there's already a text to voice library). A way of testing yourself.

Ultimately planning to implement common cw messages to test with, and hopefully a menu to control wpm
Link Posted: 7/25/2024 1:29:17 PM EDT
[#19]
Discussion ForumsJump to Quoted PostQuote History
Quoted:



This looks like it decodes cw received through the radio. I'm a long way from there!

This project goal is to have a tool to learn cw. Type your message, then see and hear the morse. Eventually, input morse, and see the text (maybe hear the text too, I know there's already a text to voice library). A way of testing yourself.

Ultimately planning to implement common cw messages to test with, and hopefully a menu to control wpm
View Quote


LCWO.net - Learn Morse Code (CW) Online

This is a good online tool for CW study.
Link Posted: 7/25/2024 8:50:18 PM EDT
[#20]
Wish I could help...



2/28/23
Link Posted: 7/25/2024 10:37:22 PM EDT
[#21]
Discussion ForumsJump to Quoted PostQuote History
View Quote



At least the bit you did earned a 5 star rating...

The Harvard CS50P course is good. There are problem sets for each week that reinforce the lessons. If you really want a deep understanding, do the CS50X first.

Indently and BroCode have excellent youtube tutorials.

I've recently found Clear Code. He makes a lot of videos about making games with pygame and godot. His videos are so good that I joined his patreon just to support him.
Link Posted: 7/27/2024 8:21:44 PM EDT
[#22]
Discussion ForumsJump to Quoted PostQuote History
Quoted:



At least the bit you did earned a 5 star rating...

The Harvard CS50P course is good. There are problem sets for each week that reinforce the lessons. If you really want a deep understanding, do the CS50X first.

Indently and BroCode have excellent youtube tutorials.

I've recently found Clear Code. He makes a lot of videos about making games with pygame and godot. His videos are so good that I joined his patreon just to support him.
View Quote


Thanks for the info, I'm just dumb I think, I am pretty sure that is what I ranked the course, my mouse is doubleclicking like mad these days.
Link Posted: 7/27/2024 8:50:37 PM EDT
[#23]
Discussion ForumsJump to Quoted PostQuote History
Quoted:
My 13-year-old thinks Python is pretty cool.

Apparently it’s a common entry level code.
View Quote


Its not just entry code. Nuclear reactor designers use it too:

ARMI
Close Join Our Mail List to Stay Up To Date! Win a FREE Membership!

Sign up for the ARFCOM weekly newsletter and be entered to win a free ARFCOM membership. One new winner* is announced every week!

You will receive an email every Friday morning featuring the latest chatter from the hottest topics, breaking news surrounding legislation, as well as exclusive deals only available to ARFCOM email subscribers.


By signing up you agree to our User Agreement. *Must have a registered ARFCOM account to win.
Top Top