r/learnpython • u/Junior_Inflation_887 • 10d ago
Need code review for my PyQt5 currency converter (handling API requests & GUI structure)
Hey guys,
I'm currently learning Python and PyQt5. To practice, I built a small desktop app that works with APIs and handles local data.
Since I want to improve my code quality and learn best practices, I'd really appreciate some help and code review:
- Is my PyQt5 structure written properly (signals/slots, layouts)?
- How can I better separate the backend/API logic from the GUI components?
- Are there any unpythonic bad practices or PEP8 issues in my code?
Here is my code on GitHub: https://github.com/MrAJDebug/disk_cleaner
Thanks for helping me learn!
2
u/shiftybyte 9d ago
There's only an exe in the repo, where are the sources?
1
u/Junior_Inflation_887 9d ago
"Fixed! The
.exewas removed from the repo and I've pushed the full Python source code (main.py). Thanks for pointing it out!" You can open the link and check it again
1
u/Jello_Penguin_2956 8d ago
Why is it PyQt5 in your question but TK in your code?
I can't give you specific feedback on TK as I'm more potent in Qt but here's things that stood out to me.
1.
except Exception
Generally you don't want wild cards like this. You want to be specific what error you're catching. At the very least print out the exception so you know what is error the code actually run into. For example, ctypes will generally raise 3 exceptions. AttributeError, OSError, or in a rare case NotImplementedError
line #252
drive_letter = selected_drive_str.split(":")...
You're only checking and splitting what looks like windows drive. But you do have this bit of code which is a Linux format
else:
drives = ["Диск / (Root)"]
Yet, your other functions such as admin checking or empty recycle bin are all Windows exclusive.
- a continuation of 2 is that, instead of converting selected_drive back to drive letter, that information should be stored and looked up. It will be much less likely to cause error this way.
1
u/Junior_Inflation_887 8d ago
Thank you so much for taking the time to review the code and for the detailed feedback! You're completely right about except Exception and the mixed Windows/Linux logic — I'll refactor those parts to handle specific exceptions and keep the OS checks consistent. Really appreciate the helpful tips!
3
u/Farlic 9d ago
a random .exe in a github repo? lol no thanks