feat: Implement search and filter functionality in MedTrackerApp

- Added DataFilter class for managing filtering and searching of medical data.
- Introduced SearchFilterWidget for UI controls related to search and filters.
- Integrated search and filter features into MedTrackerApp, allowing users to filter data by date range, medicine status, and pathology scores.
- Implemented quick filters for common use cases (last week, last month, high symptoms).
- Enhanced data loading and display logic to accommodate filtered data.
- Added error handling for data loading issues.
- Updated UIManager to reflect filter status in the application.
- Improved entry validation in add_new_entry method to ensure data integrity.
This commit is contained in:
William Valentin
2025-08-06 09:55:47 -07:00
parent 780d44775d
commit 7bb06fabdd
10 changed files with 2288 additions and 30 deletions

77
SEARCH_FILTER_FIX.md Normal file
View File

@@ -0,0 +1,77 @@
# Search Filter Panel Display Fix Summary
## Issue Description
The Search & Filter panel was not displaying all of its elements properly due to sizing constraints in the UI layout.
## Root Cause Analysis
1. **Insufficient Vertical Space**: The search filter widget was positioned in grid row 1 with `weight=0`, meaning it couldn't expand vertically when needed.
2. **Layout Constraints**: The widget was using `sticky="ew"` (only horizontal expansion) instead of allowing vertical expansion.
3. **Content Overflow**: The widget contained many elements (search box, quick filters, date range, medicine filters, pathology filters) that needed more space than allocated.
## Solutions Implemented
### 1. Grid Layout Improvements (`main.py`)
- **Added minimum height**: Set `minsize=200` for the search filter row to ensure adequate space
- **Updated row configuration**: Modified grid row configuration to properly accommodate the search filter widget
- **Better weight distribution**: Maintained main weight on the table row while giving the search filter adequate space
### 2. Search Filter Widget Enhancements (`search_filter_ui.py`)
- **Added scrollable container**: Implemented a Canvas with scrollbar for handling overflow content
- **Improved sticky configuration**: Changed from `sticky="ew"` to `sticky="nsew"` for full expansion
- **Compact layout design**: Reorganized elements to use space more efficiently:
- Reduced padding and margins throughout
- Made labels shorter (8 characters max)
- Arranged medicines in 4 columns instead of 3
- Arranged pathologies in 2 rows side-by-side
- Reduced button text sizes
### 3. User Experience Improvements
- **Mouse wheel scrolling**: Added support for mouse wheel scrolling within the filter panel
- **Cross-platform scrolling**: Implemented both Windows (`<MouseWheel>`) and Linux (`<Button-4>`, `<Button-5>`) scroll events
- **Fixed height container**: Limited the container height to 180px to prevent it from taking over the entire UI
- **Visual hierarchy**: Maintained clear separation between different filter sections
## Technical Details
### Before (Issues):
```python
# Grid configuration gave no vertical space to search filter
main_frame.grid_rowconfigure(i, weight=1 if i == 2 else 0)
# Widget couldn't expand vertically
self.frame.grid(row=1, column=0, columnspan=2, sticky="ew", padx=10, pady=5)
# No overflow handling for content
```
### After (Fixed):
```python
# Grid configuration with minimum height for search filter
if i == 1: # Search filter row
main_frame.grid_rowconfigure(i, weight=0, minsize=200)
elif i == 2: # Table row gets main weight
main_frame.grid_rowconfigure(i, weight=1)
# Widget can expand in all directions
self.frame.grid(row=1, column=0, columnspan=2, sticky="nsew", padx=10, pady=5)
# Scrollable container for overflow content
canvas = tk.Canvas(self.frame, height=180) # Limited height
scrollbar = ttk.Scrollbar(self.frame, orient="vertical", command=canvas.yview)
scrollable_frame = ttk.Frame(canvas)
```
## Results
-**All filter elements now visible**: Search box, quick filters, date range, medicine filters, and pathology filters
-**Scrollable interface**: Users can scroll through all filter options if content exceeds visible area
-**Responsive layout**: Filter panel adapts to different window sizes
-**Improved usability**: Mouse wheel scrolling and compact design improve user experience
-**Maintained functionality**: All existing search and filter capabilities work as before
## User Instructions
1. **Toggle Panel**: Press `Ctrl+F` or use "Tools → Search & Filter" menu
2. **Scroll Content**: Use mouse wheel or scrollbar to navigate through filter options
3. **Compact Interface**: All elements are now visible and accessible within the allocated space
4. **Filter Controls**: All medicine and pathology filters are fully functional and visible
The search filter panel now properly displays all its elements while maintaining a clean, organized interface that doesn't overwhelm the main application UI.