Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues #73

Open
Swaraj08tech opened this issue Oct 25, 2024 · 0 comments
Open

Issues #73

Swaraj08tech opened this issue Oct 25, 2024 · 0 comments

Comments

@Swaraj08tech
Copy link

Here are some issues in your code:

  1. File Path Compatibility (filename variable)**: The code for obtaining the current directory (script_dir) using os.path.dirname and __file__ may fail if executed as an interactive script or in certain environments like Jupyter notebooks. If the script is executed in such an environment, __file__ may not be defined, resulting in an error. A safer approach would be to use a fallback method to define script_dir or check for the presence of __file__.

  2. JSON Load Error Handling: If the JSON file is malformed, trying to load it using json.load will result in an uncaught exception. It’s better to handle this exception gracefully and create a new empty JSON file if the loading fails.

3.Global Variables Usage: The code uses multiple global variables, which may lead to bugs if any function unintentionally modifies them. Consider encapsulating the logic within a class to avoid using global variables directly.

  1. Inconsistent Input Validation: The add_item and edit_item functions check for negative values for the amount and price but don’t restrict zero values, which may be unwanted in a shopping list. A zero amount or price may not make sense in most shopping scenarios.

  2. Updating Items by Amount Only: The add_item function only updates the amount of an existing item. This means that if you want to change the price or category, you need to manually remove and add the item again. This could be inconvenient for users.

  3. Combobox Category Filter All: The combobox_category contains all categories except "All", but "All" is needed only for filtering, not for assigning a category. Ensure that the logic correctly excludes "All" where necessary.

  4. Search Functionality: The search function searches based on substrings within the item name. However, it doesn't highlight or indicate what part of the search term matches the item name. This may make it difficult for users to identify results quickly.

  5. Lack of Function for Clearing Entry Fields: There's a clear_entries function that resets all entry fields, but it doesn’t clear the displayed filter in the combobox_filter. This can lead to the filter retaining its previous state even after modifications, which might be confusing for the user.

  6. UI Consistency for Different Platforms: The GUI styling (e.g., background colors) may not render consistently across different platforms like Windows, macOS, and Linux. Testing on multiple platforms would help ensure consistent look and feel.

  7. Data Integrity Checks: When removing items or editing amounts, the code assumes that the entry field contains valid item names. However, if there’s a spelling error or if the item is not found in the list, the user only gets an error message. It might be better to show a list of matching items or to auto-suggest based on partial inputs.

  8. Displaying Amount and Price with Zero Decimal Places: The display_list function displays amounts and prices using a single decimal format (.2f), which may not be needed for integer amounts. Consider formatting amounts appropriately based on context.

  9. Listbox Not Refreshing Properly: When adding, removing, or editing an item, the display_list function doesn’t refresh the entire list in some cases if a specific filter is active. Ensure that filters are reset or re-applied correctly.

  10. UI Responsiveness: The GUI layout uses hard-coded row and column configurations, which may not adapt well to different window sizes. Consider using more flexible layouts to make the app responsive.

If you would like, I can suggest improvements or refactor your code to address these issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant