Overview
This prompt guides the improvement of a Python financial app’s code quality and user experience. Developers and end-users will benefit from the resulting robust, maintainable application.
Prompt Overview
Purpose: To manage personal finances by recording and summarizing transactions.
Audience: Users needing a simple desktop app for tracking income and expenses.
Distinctive Feature: Uses CSV for data storage with basic validation and summary.
Outcome: Provides a clear transaction log and current balance display.
Quick Specs
- Media: Text
- Use case: Generation
- Industry: Productivity & Workflow, General Business Operations, Banking (Retail & Commercial)
- Techniques: Decomposition, Self-Critique / Reflection, Structured Output
- Models: GPT-4, Claude 3 Opus, Llama 4 Maverick
- Estimated time: 5-10 minutes
- Skill level: Beginner
Variables to Fill
No inputs required — just copy and use the prompt.
Example Variables Block
No example values needed for this prompt.
The Prompt
You are given a Python script that implements a simple financial management application using Tkinter. Your task is to analyze and improve this script for better functionality, robustness, readability, and user experience.
Focus on the following aspects:
– **Bug Fixes**: Identify and correct any errors or potential crashes, such as variable scope issues or unhandled exceptions.
– **Code Quality**: Refactor code for clarity, modularity, and adherence to Python best practices.
– **User Input Validation**: Enhance input validation (e.g., date format checking, non-empty descriptions).
– **User Feedback**: Provide clear and consistent feedback messages.
– **Extensibility**: Make the code easier to extend with new features (e.g., improved file handling, better UI layout).
– **Comments and Documentation**: Ensure all functions and key parts of the code have clear comments.
Before making changes, think carefully about how each part works and identify potential improvements.
# Steps
1. Review the entire script to understand its structure and logic.
2. Identify any immediate bugs or problems (for example, `ringkasan_label` usage outside its scope).
3. Improve the `catat_transaksi` function to validate the date format (`YYYY-MM-DD`), ensure `deskripsi` is not empty, and validate `jumlah` is a positive number.
4. Modify the `load_data` function to handle corrupted or incomplete CSV data gracefully.
5. Refactor the GUI layout as needed for better resizing behavior and widget placement.
6. Add comments where missing or unclear.
7. Ensure message boxes show helpful and consistent messages.
8. Minimize global variables and ensure the code follows good practices.
# Output Format
Return the full, improved script with all corrections and enhancements applied, suitable for immediate execution. Keep the original functionality intact while making the program more robust and user-friendly.
# Notes
– Use `datetime.strptime()` for date validation.
– Use try-except blocks for file operations and conversions.
– Avoid using global variables unless necessary.
– Keep the UI responsive and avoid blocking calls.
# Examples
– If the user enters an invalid date, the program should display an error message and not accept the input.
– If the CSV file is not found or corrupted, the program initializes with empty data but does not crash.
Screenshot Examples
[Insert relevant screenshots after testing]
How to Use This Prompt
- Copy the prompt into your text editor or IDE.
- Review the Python script for structure and logic understanding.
- Identify and fix bugs, focusing on variable scope and exceptions.
- Refactor code for clarity, modularity, and Python best practices.
- Enhance input validation and user feedback mechanisms.
- Ensure code is well-documented with comments and follows good practices.
Tips for Best Results
- Bug Fixes: Ensure all variables are correctly scoped and handle exceptions to prevent crashes.
- Code Quality: Refactor code into functions and modules, following Python’s PEP 8 guidelines for readability.
- User Input Validation: Implement checks for date format, non-empty descriptions, and positive numbers to ensure data integrity.
- User Feedback: Use consistent and informative message boxes to guide users through errors and confirmations.
FAQ
- What is the purpose of Tkinter in Python?
Tkinter is used to create graphical user interfaces (GUIs) in Python applications. - How can you validate a date format in Python?
Use `datetime.strptime()` to check if a date string matches a specific format. - Why is input validation important in applications?
Input validation ensures data integrity and prevents errors or security vulnerabilities. - What is a common method to handle file errors in Python?
Use try-except blocks to catch and handle exceptions during file operations.
Compliance and Best Practices
- Best Practice: Review AI output for accuracy and relevance before use.
- Privacy: Avoid sharing personal, financial, or confidential data in prompts.
- Platform Policy: Your use of AI tools must comply with their terms and your local laws.
Revision History
- Version 1.0 (March 2026): Initial release.


