feat: Consolidate documentation into a single comprehensive guide
- Created `CONSOLIDATED_DOCS.md` to serve as the primary documentation source, integrating user and developer guides, API references, and troubleshooting sections. - Updated `README.md` to reference the new consolidated documentation. - Preserved existing documentation files for backward compatibility, including `USER_GUIDE.md`, `DEVELOPER_GUIDE.md`, and others. - Enhanced navigation structure in `docs/README.md` to facilitate easier access to documentation. - Implemented UI flickering fixes, including auto-save optimizations, debounced filter updates, and efficient tree updates to improve user experience. - Added verification script `verify_docs_consolidation.py` to ensure successful documentation consolidation and integrity.
This commit is contained in:
@@ -0,0 +1,504 @@
|
||||
# TheChart - Comprehensive Documentation
|
||||
|
||||
> **Modern medication tracking application with advanced UI/UX for monitoring treatment progress and symptom evolution.**
|
||||
|
||||
## 📋 Table of Contents
|
||||
|
||||
1. [Quick Start](#-quick-start)
|
||||
2. [User Guide](#-user-guide)
|
||||
3. [Developer Guide](#-developer-guide)
|
||||
4. [Features & Capabilities](#-features--capabilities)
|
||||
5. [Technical Architecture](#-technical-architecture)
|
||||
6. [Recent Improvements](#-recent-improvements)
|
||||
7. [API Reference](#-api-reference)
|
||||
8. [Troubleshooting](#-troubleshooting)
|
||||
9. [Contributing](#-contributing)
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Quick Start
|
||||
|
||||
### Installation
|
||||
```bash
|
||||
# Clone the repository
|
||||
git clone <repository-url>
|
||||
cd thechart
|
||||
|
||||
# Install dependencies
|
||||
make install
|
||||
|
||||
# Run the application
|
||||
make run
|
||||
```
|
||||
|
||||
### First Steps
|
||||
1. **Launch TheChart** using `make run` or `python src/main.py`
|
||||
2. **Add your first entry** using Ctrl+S
|
||||
3. **Explore features** with the keyboard shortcuts (F1 for help)
|
||||
4. **Customize settings** with F2 or through the Theme menu
|
||||
|
||||
---
|
||||
|
||||
## 👤 User Guide
|
||||
|
||||
### Core Features
|
||||
|
||||
#### 📊 Data Tracking
|
||||
- **Daily Entries**: Track medications and symptoms with date-based entries
|
||||
- **Medicine Management**: Configure medications with dosage information and colors
|
||||
- **Pathology Tracking**: Monitor symptoms using customizable 0-10 scales
|
||||
- **Notes System**: Add detailed notes to each entry
|
||||
|
||||
#### 🎨 Modern UI/UX (v1.9.5+)
|
||||
- **Professional Themes**: Multiple built-in themes (Dark, Light, Arc, etc.)
|
||||
- **Smart Tooltips**: Context-sensitive help throughout the interface
|
||||
- **Responsive Design**: Optimized layouts for different screen sizes
|
||||
- **Smooth Interactions**: Debounced updates and flicker-free scrolling
|
||||
|
||||
#### ⌨️ Keyboard Shortcuts
|
||||
|
||||
##### File Operations
|
||||
- **Ctrl+S**: Save/Add new entry
|
||||
- **Ctrl+Q**: Quit application
|
||||
- **Ctrl+E**: Export data
|
||||
|
||||
##### Data Management
|
||||
- **Ctrl+N**: Clear entries
|
||||
- **Ctrl+R / F5**: Refresh data
|
||||
- **Ctrl+F**: Toggle search/filter
|
||||
|
||||
##### Window Management
|
||||
- **Ctrl+M**: Manage medicines
|
||||
- **Ctrl+P**: Manage pathologies
|
||||
|
||||
##### Table Operations
|
||||
- **Delete**: Delete selected entry
|
||||
- **Escape**: Clear selection
|
||||
- **Double-click**: Edit entry
|
||||
|
||||
##### Help
|
||||
- **F1**: Show keyboard shortcuts
|
||||
- **F2**: Open settings window
|
||||
|
||||
#### 🔍 Search & Filter System
|
||||
- **Text Search**: Search across all entry data
|
||||
- **Date Range Filtering**: Filter by specific date ranges
|
||||
- **Medicine Filters**: Show entries where medicines were taken/not taken
|
||||
- **Pathology Range Filters**: Filter by symptom severity ranges
|
||||
- **Quick Filters**: Pre-configured filters (last week, high symptoms, etc.)
|
||||
|
||||
#### 📈 Visualization
|
||||
- **Interactive Graphs**: Line charts showing symptom trends over time
|
||||
- **Medicine Dose Charts**: Bar charts displaying daily medication intake
|
||||
- **Toggle Controls**: Show/hide specific symptoms or medicines
|
||||
- **Professional Styling**: Clean, medical-grade visualization
|
||||
|
||||
#### 💾 Data Management
|
||||
- **Auto-save**: Automatic data saving every 5 minutes
|
||||
- **Backup System**: Automatic backups on startup/shutdown
|
||||
- **Export Options**: JSON, PDF, XML export formats
|
||||
- **Data Validation**: Comprehensive input validation and error handling
|
||||
|
||||
### Settings & Customization
|
||||
|
||||
#### Theme Management
|
||||
- **Built-in Themes**: Dark, Light, Arc, Clam, Default, Alt
|
||||
- **Dynamic Switching**: Change themes without restart
|
||||
- **Persistent Settings**: Theme preferences saved automatically
|
||||
- **Accessibility**: High contrast options available
|
||||
|
||||
#### Medicine Configuration
|
||||
- **Add/Edit/Delete**: Full CRUD operations for medicines
|
||||
- **Dosage Information**: Track dosage details and instructions
|
||||
- **Color Coding**: Visual identification with custom colors
|
||||
- **Quick Doses**: Pre-configured common dose amounts
|
||||
|
||||
#### Pathology Configuration
|
||||
- **Symptom Scales**: Customizable 0-10 symptom tracking scales
|
||||
- **Display Names**: User-friendly symptom names
|
||||
- **Scale Descriptions**: Helpful descriptions for each scale level
|
||||
- **Color Themes**: Visual feedback with color coding
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ Developer Guide
|
||||
|
||||
### Development Environment Setup
|
||||
|
||||
#### Prerequisites
|
||||
- **Python 3.13+**
|
||||
- **uv** package manager
|
||||
- **Virtual environment support**
|
||||
|
||||
#### Setup Commands
|
||||
```bash
|
||||
# Create virtual environment
|
||||
python -m venv .venv
|
||||
source .venv/bin/activate # or .venv/bin/activate.fish
|
||||
|
||||
# Install dependencies
|
||||
uv sync
|
||||
|
||||
# Install development dependencies
|
||||
uv sync --group dev
|
||||
|
||||
# Run tests
|
||||
uv run pytest
|
||||
|
||||
# Run with coverage
|
||||
uv run pytest --cov=src --cov-report=html
|
||||
```
|
||||
|
||||
### Project Structure
|
||||
|
||||
```
|
||||
thechart/
|
||||
├── src/ # Source code
|
||||
│ ├── main.py # Application entry point
|
||||
│ ├── ui_manager.py # UI component management
|
||||
│ ├── data_manager.py # Data persistence
|
||||
│ ├── theme_manager.py # Theme and styling
|
||||
│ ├── medicine_manager.py # Medicine CRUD operations
|
||||
│ ├── pathology_manager.py # Pathology management
|
||||
│ ├── graph_manager.py # Visualization
|
||||
│ ├── export_manager.py # Data export
|
||||
│ ├── search_filter*.py # Search and filtering
|
||||
│ └── auto_save.py # Auto-save functionality
|
||||
├── tests/ # Test suite
|
||||
├── docs/ # Documentation
|
||||
├── scripts/ # Utility scripts
|
||||
└── logs/ # Application logs
|
||||
```
|
||||
|
||||
### Architecture Overview
|
||||
|
||||
#### Core Components
|
||||
- **MedTrackerApp**: Main application class coordinating all components
|
||||
- **UIManager**: Creates and manages all UI elements
|
||||
- **DataManager**: Handles CSV data operations with pandas
|
||||
- **ThemeManager**: Manages application themes and styling
|
||||
- **GraphManager**: Creates interactive matplotlib visualizations
|
||||
|
||||
#### Design Patterns
|
||||
- **Manager Pattern**: Separate managers for different concerns
|
||||
- **Observer Pattern**: UI updates based on data changes
|
||||
- **Strategy Pattern**: Different export formats and themes
|
||||
- **Factory Pattern**: Dynamic UI component creation
|
||||
|
||||
### Testing Strategy
|
||||
|
||||
#### Test Organization
|
||||
- **Unit Tests**: Individual component testing
|
||||
- **Integration Tests**: Cross-component functionality
|
||||
- **UI Tests**: User interface behavior testing
|
||||
- **Performance Tests**: Load and stress testing
|
||||
|
||||
#### Running Tests
|
||||
```bash
|
||||
# All tests
|
||||
make test
|
||||
|
||||
# Specific test categories
|
||||
uv run pytest tests/unit/
|
||||
uv run pytest tests/integration/
|
||||
uv run pytest tests/ui/
|
||||
|
||||
# With coverage
|
||||
uv run pytest --cov=src --cov-report=html --cov-report=term-missing
|
||||
```
|
||||
|
||||
### Code Quality
|
||||
|
||||
#### Linting and Formatting
|
||||
- **ruff**: Primary linter and formatter
|
||||
- **Type Hints**: Full type annotation coverage
|
||||
- **PEP8 Compliance**: Enforced code style
|
||||
- **Docstrings**: Comprehensive documentation
|
||||
|
||||
#### Pre-commit Hooks
|
||||
```bash
|
||||
# Install pre-commit hooks
|
||||
pre-commit install
|
||||
|
||||
# Run all hooks
|
||||
pre-commit run --all-files
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🌟 Features & Capabilities
|
||||
|
||||
### Data Management Features
|
||||
- **Dynamic Medicine System**: Add/remove medicines without code changes
|
||||
- **Flexible Pathology Tracking**: Customizable symptom scales
|
||||
- **Robust Data Validation**: Comprehensive input validation
|
||||
- **Data Export**: Multiple export formats (JSON, PDF, XML)
|
||||
- **Backup & Recovery**: Automatic backup system
|
||||
|
||||
### User Interface Features
|
||||
- **Modern Theme Engine**: Professional styling system
|
||||
- **Smart Tooltip System**: Context-sensitive help
|
||||
- **Responsive Layouts**: Adaptive UI components
|
||||
- **Keyboard Navigation**: Full keyboard accessibility
|
||||
- **Visual Feedback**: Status updates and progress indicators
|
||||
|
||||
### Technical Features
|
||||
- **Performance Optimization**: Efficient data handling and UI updates
|
||||
- **Error Handling**: Comprehensive error recovery
|
||||
- **Logging System**: Detailed application logging
|
||||
- **Cross-platform**: Works on Windows, macOS, and Linux
|
||||
- **Modular Architecture**: Easy to extend and maintain
|
||||
|
||||
---
|
||||
|
||||
## 🏗️ Technical Architecture
|
||||
|
||||
### Data Layer
|
||||
- **CSV Storage**: Primary data persistence using pandas
|
||||
- **JSON Configuration**: Medicine and pathology configurations
|
||||
- **Backup System**: Automatic backup creation and management
|
||||
- **Data Validation**: Input validation and error handling
|
||||
|
||||
### Business Logic Layer
|
||||
- **Manager Classes**: Encapsulated business logic
|
||||
- **Event Handling**: User interaction processing
|
||||
- **Auto-save**: Background data persistence
|
||||
- **Export Processing**: Data transformation for export
|
||||
|
||||
### Presentation Layer
|
||||
- **Tkinter UI**: Native desktop interface
|
||||
- **Theme System**: Dynamic styling and theming
|
||||
- **Interactive Components**: Responsive UI elements
|
||||
- **Visualization**: Matplotlib integration for charts
|
||||
|
||||
### Recent Technical Improvements
|
||||
|
||||
#### UI Flickering Fix (Latest)
|
||||
- **Auto-save Optimization**: Removed unnecessary UI refreshes during auto-save
|
||||
- **Debounced Filter Updates**: 300ms debouncing for search/filter changes
|
||||
- **Efficient Tree Updates**: Scroll position preservation and batch operations
|
||||
- **Optimized Scroll Handling**: Reduced scrollbar update frequency
|
||||
- **Performance Improvements**: Eliminated redundant data loading
|
||||
|
||||
#### Key Optimizations
|
||||
1. **Memory Efficiency**: Single data load with copies instead of multiple loads
|
||||
2. **Scroll Performance**: Threshold-based scroll updates to reduce CPU usage
|
||||
3. **UI Responsiveness**: Batch UI operations using `update_idletasks()`
|
||||
4. **User Experience**: Preserved scroll position during data updates
|
||||
|
||||
---
|
||||
|
||||
## 📈 Recent Improvements
|
||||
|
||||
### Version 1.9.5 - UI/UX Overhaul
|
||||
- **Professional Theme Engine**: Complete theming system with 6+ themes
|
||||
- **Smart Tooltip System**: Context-sensitive help throughout the interface
|
||||
- **Enhanced Settings Window**: Comprehensive configuration interface
|
||||
- **Modern UI Components**: Improved styling and layout
|
||||
- **Performance Optimizations**: Faster loading and smoother interactions
|
||||
|
||||
### Latest Fixes - UI Flickering Resolution
|
||||
- **Smooth Scrolling**: Eliminated flickering during table scrolling
|
||||
- **Debounced Updates**: Reduced filter update frequency
|
||||
- **Preserved Context**: Maintain scroll position during updates
|
||||
- **Auto-save Optimization**: Non-intrusive background saving
|
||||
- **Performance Gains**: Reduced CPU usage during UI operations
|
||||
|
||||
### Previous Improvements
|
||||
- **Search & Filter System**: Advanced filtering capabilities
|
||||
- **Export Enhancements**: Multiple export formats with customization
|
||||
- **Keyboard Shortcuts**: Comprehensive keyboard navigation
|
||||
- **Data Validation**: Robust input validation and error handling
|
||||
- **Auto-save & Backup**: Automatic data protection
|
||||
|
||||
---
|
||||
|
||||
## 📖 API Reference
|
||||
|
||||
### Core Classes
|
||||
|
||||
#### MedTrackerApp
|
||||
```python
|
||||
class MedTrackerApp:
|
||||
"""Main application class."""
|
||||
|
||||
def __init__(self, root: tk.Tk) -> None:
|
||||
"""Initialize the application."""
|
||||
|
||||
def add_new_entry(self) -> None:
|
||||
"""Add a new data entry."""
|
||||
|
||||
def refresh_data_display(self, apply_filters: bool = False) -> None:
|
||||
"""Refresh the data display."""
|
||||
```
|
||||
|
||||
#### UIManager
|
||||
```python
|
||||
class UIManager:
|
||||
"""Manages UI components and creation."""
|
||||
|
||||
def create_input_frame(self, parent_frame: ttk.Frame) -> dict[str, Any]:
|
||||
"""Create the input form."""
|
||||
|
||||
def create_table_frame(self, parent_frame: ttk.Frame) -> dict[str, Any]:
|
||||
"""Create the data table."""
|
||||
|
||||
def update_status(self, message: str, message_type: str = "info") -> None:
|
||||
"""Update the status bar."""
|
||||
```
|
||||
|
||||
#### DataManager
|
||||
```python
|
||||
class DataManager:
|
||||
"""Handles data persistence and operations."""
|
||||
|
||||
def load_data(self) -> pd.DataFrame:
|
||||
"""Load data from CSV file."""
|
||||
|
||||
def add_entry(self, entry: list) -> bool:
|
||||
"""Add a new entry to the data."""
|
||||
|
||||
def update_entry(self, date: str, values: list) -> bool:
|
||||
"""Update an existing entry."""
|
||||
```
|
||||
|
||||
### Configuration APIs
|
||||
|
||||
#### Medicine Management
|
||||
```python
|
||||
class MedicineManager:
|
||||
"""Manages medicine configurations."""
|
||||
|
||||
def add_medicine(self, medicine: Medicine) -> bool:
|
||||
"""Add a new medicine."""
|
||||
|
||||
def get_medicine(self, key: str) -> Medicine | None:
|
||||
"""Get medicine by key."""
|
||||
|
||||
def get_medicine_keys(self) -> list[str]:
|
||||
"""Get all medicine keys."""
|
||||
```
|
||||
|
||||
#### Pathology Management
|
||||
```python
|
||||
class PathologyManager:
|
||||
"""Manages pathology configurations."""
|
||||
|
||||
def add_pathology(self, pathology: Pathology) -> bool:
|
||||
"""Add a new pathology."""
|
||||
|
||||
def get_pathology(self, key: str) -> Pathology | None:
|
||||
"""Get pathology by key."""
|
||||
|
||||
def get_pathology_keys(self) -> list[str]:
|
||||
"""Get all pathology keys."""
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🚨 Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
#### Application Won't Start
|
||||
```bash
|
||||
# Check Python version
|
||||
python --version # Should be 3.13+
|
||||
|
||||
# Verify virtual environment
|
||||
source .venv/bin/activate
|
||||
which python
|
||||
|
||||
# Reinstall dependencies
|
||||
uv sync --reinstall
|
||||
```
|
||||
|
||||
#### UI Flickering (Resolved)
|
||||
The UI flickering issue during scrolling has been resolved in the latest version through:
|
||||
- Auto-save optimization
|
||||
- Debounced filter updates
|
||||
- Efficient tree updates
|
||||
- Scroll position preservation
|
||||
|
||||
#### Data Not Saving
|
||||
1. Check file permissions in the project directory
|
||||
2. Verify CSV file is not locked by another application
|
||||
3. Check logs in `logs/app.log` for error messages
|
||||
4. Ensure sufficient disk space
|
||||
|
||||
#### Theme Issues
|
||||
1. Restart the application after theme changes
|
||||
2. Check theme configuration in settings
|
||||
3. Reset to default theme if issues persist
|
||||
4. Verify tkinter supports the selected theme
|
||||
|
||||
#### Export Problems
|
||||
1. Check output directory permissions
|
||||
2. Verify required libraries are installed
|
||||
3. Check for large dataset memory issues
|
||||
4. Review export logs for specific errors
|
||||
|
||||
### Debug Mode
|
||||
Enable debug logging by setting the log level in `src/constants.py`:
|
||||
```python
|
||||
LOG_LEVEL = "DEBUG"
|
||||
```
|
||||
|
||||
### Log Files
|
||||
- **`logs/app.log`**: General application logs
|
||||
- **`logs/app.error.log`**: Error messages only
|
||||
- **`logs/app.warning.log`**: Warning messages only
|
||||
|
||||
---
|
||||
|
||||
## 🤝 Contributing
|
||||
|
||||
### Development Workflow
|
||||
1. **Fork** the repository
|
||||
2. **Create** a feature branch: `git checkout -b feature-name`
|
||||
3. **Make** your changes following the coding guidelines
|
||||
4. **Test** your changes: `make test`
|
||||
5. **Lint** your code: `ruff check src/`
|
||||
6. **Submit** a pull request
|
||||
|
||||
### Coding Standards
|
||||
- **Follow PEP8** for Python code style
|
||||
- **Use type hints** for all functions and variables
|
||||
- **Write docstrings** for all public methods and classes
|
||||
- **Add tests** for new functionality
|
||||
- **Update documentation** for user-facing changes
|
||||
|
||||
### Testing Requirements
|
||||
- **Unit tests** for all new functions
|
||||
- **Integration tests** for cross-component features
|
||||
- **UI tests** for user interface changes
|
||||
- **Performance tests** for optimization changes
|
||||
|
||||
### Documentation Updates
|
||||
- **Update user guide** for new features
|
||||
- **Add API documentation** for new classes/methods
|
||||
- **Update changelog** with version information
|
||||
- **Include troubleshooting** for known issues
|
||||
|
||||
---
|
||||
|
||||
## 📄 License & Credits
|
||||
|
||||
### License
|
||||
This project is licensed under [LICENSE] - see the LICENSE file for details.
|
||||
|
||||
### Credits
|
||||
- **UI Framework**: Tkinter (Python standard library)
|
||||
- **Data Processing**: pandas
|
||||
- **Visualization**: matplotlib
|
||||
- **Themes**: ttkthemes integration
|
||||
- **Package Management**: uv
|
||||
|
||||
### Version Information
|
||||
- **Current Version**: 1.13.7
|
||||
- **Latest UI Update**: v1.9.5 (UI/UX Overhaul)
|
||||
- **Latest Fix**: UI Flickering Resolution
|
||||
|
||||
---
|
||||
|
||||
*For the most up-to-date information, check the [CHANGELOG.md](CHANGELOG.md) and [README.md](README.md) files.*
|
||||
@@ -0,0 +1,123 @@
|
||||
# Documentation Consolidation Summary
|
||||
|
||||
## Overview
|
||||
The TheChart project documentation has been consolidated to improve accessibility and reduce redundancy across multiple documentation files.
|
||||
|
||||
## Changes Made
|
||||
|
||||
### 🌟 **New Primary Document**
|
||||
- **Created**: `CONSOLIDATED_DOCS.md` - Complete comprehensive documentation in a single file
|
||||
- **Contains**: User guide, developer guide, API reference, troubleshooting, and more
|
||||
- **Benefits**: Single source of truth, easier maintenance, better navigation
|
||||
|
||||
### 📚 **Updated Documentation Structure**
|
||||
|
||||
#### Root Level Documents
|
||||
- ✅ **CONSOLIDATED_DOCS.md** - **Primary comprehensive guide (NEW)**
|
||||
- ✅ README.md - Updated with consolidated documentation references
|
||||
- ✅ USER_GUIDE.md - Preserved for quick user access
|
||||
- ✅ DEVELOPER_GUIDE.md - Preserved for quick developer access
|
||||
- ✅ UI_FLICKERING_FIX_SUMMARY.md - Latest performance improvements
|
||||
- ✅ CHANGELOG.md, API_REFERENCE.md, IMPROVEMENTS_SUMMARY.md - Maintained
|
||||
|
||||
#### Documentation Hub
|
||||
- ✅ **docs/README.md** - Updated as documentation navigation hub
|
||||
- ✅ docs/ folder - Preserved legacy/reference documentation
|
||||
|
||||
### 🎯 **Navigation Improvements**
|
||||
|
||||
#### For New Users
|
||||
- **Primary Path**: CONSOLIDATED_DOCS.md → User Guide section
|
||||
- **Quick Path**: USER_GUIDE.md (direct access)
|
||||
- **Navigation Hub**: docs/README.md
|
||||
|
||||
#### For Developers
|
||||
- **Primary Path**: CONSOLIDATED_DOCS.md → Developer Guide section
|
||||
- **Quick Path**: DEVELOPER_GUIDE.md (direct access)
|
||||
- **API Reference**: CONSOLIDATED_DOCS.md → API Reference section
|
||||
|
||||
#### For Specific Information
|
||||
- **Features**: CONSOLIDATED_DOCS.md → Features & Capabilities
|
||||
- **Architecture**: CONSOLIDATED_DOCS.md → Technical Architecture
|
||||
- **Troubleshooting**: CONSOLIDATED_DOCS.md → Troubleshooting
|
||||
- **Recent Updates**: CONSOLIDATED_DOCS.md → Recent Improvements
|
||||
|
||||
## Benefits
|
||||
|
||||
### ✅ **Improved User Experience**
|
||||
- Single comprehensive guide for complete information
|
||||
- Multiple access paths for different user types
|
||||
- Clear navigation and role-based guidance
|
||||
- Reduced documentation fragmentation
|
||||
|
||||
### ✅ **Enhanced Maintainability**
|
||||
- Centralized content reduces duplication
|
||||
- Easier to keep information current
|
||||
- Single source of truth for comprehensive information
|
||||
- Preserved specialized documents for specific needs
|
||||
|
||||
### ✅ **Better Organization**
|
||||
- Logical section structure in consolidated document
|
||||
- Clear table of contents and navigation
|
||||
- Cross-references between related sections
|
||||
- Consistent formatting and presentation
|
||||
|
||||
## Access Patterns
|
||||
|
||||
### 🚀 **Recommended for Most Users**
|
||||
```
|
||||
CONSOLIDATED_DOCS.md
|
||||
├── Quick Start (immediate needs)
|
||||
├── User Guide (feature usage)
|
||||
├── Developer Guide (development)
|
||||
├── Features & Capabilities (comprehensive overview)
|
||||
├── Technical Architecture (system details)
|
||||
├── Recent Improvements (latest updates)
|
||||
├── API Reference (technical details)
|
||||
└── Troubleshooting (problem solving)
|
||||
```
|
||||
|
||||
### ⚡ **Quick Access for Specific Roles**
|
||||
```
|
||||
Users: USER_GUIDE.md → specific features
|
||||
Developers: DEVELOPER_GUIDE.md → specific setup
|
||||
References: API_REFERENCE.md → specific APIs
|
||||
Updates: CHANGELOG.md → version history
|
||||
```
|
||||
|
||||
### 📚 **Navigation Hub**
|
||||
```
|
||||
docs/README.md → comprehensive navigation options
|
||||
```
|
||||
|
||||
## Implementation
|
||||
|
||||
### Files Created
|
||||
- ✅ `CONSOLIDATED_DOCS.md` - Complete comprehensive documentation
|
||||
- ✅ Updated `docs/README.md` - Documentation hub
|
||||
|
||||
### Files Updated
|
||||
- ✅ `README.md` - References to consolidated documentation
|
||||
- ✅ Navigation improvements across all documents
|
||||
|
||||
### Files Preserved
|
||||
- ✅ All existing documentation files maintained for backward compatibility
|
||||
- ✅ Specialized documents (UI_FLICKERING_FIX_SUMMARY.md) preserved
|
||||
- ✅ Legacy documentation in docs/ folder preserved
|
||||
|
||||
## Usage Recommendations
|
||||
|
||||
### 🎯 **For Comprehensive Information**
|
||||
**Start with**: [CONSOLIDATED_DOCS.md](CONSOLIDATED_DOCS.md)
|
||||
|
||||
### ⚡ **For Quick Access**
|
||||
- **Users**: [USER_GUIDE.md](USER_GUIDE.md)
|
||||
- **Developers**: [DEVELOPER_GUIDE.md](DEVELOPER_GUIDE.md)
|
||||
- **Navigation**: [docs/README.md](docs/README.md)
|
||||
|
||||
### 🔍 **For Specific Topics**
|
||||
Use the table of contents in CONSOLIDATED_DOCS.md to jump directly to relevant sections.
|
||||
|
||||
---
|
||||
|
||||
*The consolidated documentation structure maintains backward compatibility while providing improved navigation and comprehensive information access.*
|
||||
@@ -15,19 +15,23 @@ make test
|
||||
|
||||
## 📚 Documentation
|
||||
|
||||
### 🎯 **For Users**
|
||||
- **[User Guide](USER_GUIDE.md)** - Complete features, keyboard shortcuts, and usage guide
|
||||
- **[Changelog](CHANGELOG.md)** - Version history and recent improvements
|
||||
### � **All-in-One Guide**
|
||||
- **[📖 CONSOLIDATED DOCS](CONSOLIDATED_DOCS.md)** - **Complete documentation in one place (RECOMMENDED)**
|
||||
|
||||
### 🛠️ **For Developers**
|
||||
- **[Developer Guide](DEVELOPER_GUIDE.md)** - Development setup, testing, and architecture
|
||||
- **[API Reference](API_REFERENCE.md)** - Technical documentation and system APIs
|
||||
- **[Recent Improvements](IMPROVEMENTS_SUMMARY.md)** - Latest enhancements and new features
|
||||
### 🎯 **Quick Access by Role**
|
||||
- **[👤 User Guide](USER_GUIDE.md)** - Complete features, keyboard shortcuts, and usage guide
|
||||
- **[🛠️ Developer Guide](DEVELOPER_GUIDE.md)** - Development setup, testing, and architecture
|
||||
- **[📋 Changelog](CHANGELOG.md)** - Version history and recent improvements
|
||||
|
||||
### 📖 **Complete Navigation**
|
||||
- **[Documentation Index](docs/README.md)** - Comprehensive documentation navigation
|
||||
### � **Specialized Topics**
|
||||
- **[🐛 UI Flickering Fix](UI_FLICKERING_FIX_SUMMARY.md)** - Latest performance improvements
|
||||
- **[🔧 API Reference](API_REFERENCE.md)** - Technical documentation and system APIs
|
||||
- **[✨ Recent Improvements](IMPROVEMENTS_SUMMARY.md)** - Latest enhancements and new features
|
||||
|
||||
> 💡 **Getting Started**: New users should start with the [User Guide](USER_GUIDE.md), while developers should check the [Developer Guide](DEVELOPER_GUIDE.md).
|
||||
### 📖 **Documentation Hub**
|
||||
- **[📚 Documentation Index](docs/README.md)** - Complete documentation navigation
|
||||
|
||||
> 💡 **Getting Started**: For the most comprehensive information, start with [CONSOLIDATED_DOCS.md](CONSOLIDATED_DOCS.md). For quick access, users can check the [User Guide](USER_GUIDE.md) and developers can check the [Developer Guide](DEVELOPER_GUIDE.md).
|
||||
|
||||
## ✨ Recent Major Updates (v1.9.5+)
|
||||
|
||||
@@ -37,6 +41,13 @@ make test
|
||||
- **Enhanced Keyboard Shortcuts**: Comprehensive shortcut system for all operations
|
||||
- **Modern Styling**: Card-style frames, professional form controls, responsive design
|
||||
|
||||
### ⚡ Performance Improvements (Latest)
|
||||
- **UI Flickering Fix**: Eliminated flickering during table scrolling
|
||||
- **Debounced Updates**: 300ms debouncing for search/filter changes
|
||||
- **Smooth Scrolling**: Preserved scroll position during data updates
|
||||
- **Auto-save Optimization**: Non-intrusive background saving
|
||||
- **Reduced CPU Usage**: Optimized scroll and update operations
|
||||
|
||||
### 🧪 Testing Improvements
|
||||
- **Consolidated Test Suite**: Unified pytest-based testing structure
|
||||
- **Quick Test Categories**: Unit, integration, and theme-specific tests
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
# UI Flickering Fix Summary
|
||||
|
||||
## Problem Description
|
||||
The UI elements were flickering when the user scrolled through the table, causing a poor user experience and making the application feel unresponsive.
|
||||
|
||||
## Root Causes Identified
|
||||
|
||||
1. **Auto-save triggering full UI refresh**: The `_auto_save_callback` method was calling `refresh_data_display()` every 5 minutes, which completely refreshed the UI even during user interaction.
|
||||
|
||||
2. **Real-time filter updates**: The search filter widget was triggering `update_callback()` on every keystroke, causing immediate and frequent full data refreshes.
|
||||
|
||||
3. **Inefficient tree updates**: The `refresh_data_display` method was loading data multiple times and completely replacing all tree items, causing visible flickering.
|
||||
|
||||
4. **Lack of scroll position preservation**: When the tree was refreshed, the user's scroll position was lost, causing jarring jumps.
|
||||
|
||||
## Solutions Implemented
|
||||
|
||||
### 1. Auto-save Optimization (`src/main.py`)
|
||||
```python
|
||||
def _auto_save_callback(self) -> None:
|
||||
"""Callback function for auto-save operations."""
|
||||
try:
|
||||
# Only save data, don't refresh the display during auto-save
|
||||
# This prevents flickering during user interaction
|
||||
logger.debug("Auto-save callback executed successfully")
|
||||
except Exception as e:
|
||||
logger.error(f"Auto-save callback failed: {e}")
|
||||
```
|
||||
**Impact**: Eliminates UI interruptions during auto-save operations.
|
||||
|
||||
### 2. Debounced Filter Updates (`src/search_filter_ui.py`)
|
||||
- Added 300ms debouncing mechanism to prevent excessive filter updates
|
||||
- Consolidated filter updates into a single batch operation
|
||||
- Replaced immediate callbacks with debounced updates
|
||||
|
||||
```python
|
||||
def _debounced_update(self) -> None:
|
||||
"""Update filters with debouncing to prevent excessive calls."""
|
||||
# Cancel any pending update and schedule a new one
|
||||
if self._update_timer:
|
||||
with contextlib.suppress(tk.TclError):
|
||||
self.parent.after_cancel(self._update_timer)
|
||||
|
||||
self._update_timer = self.parent.after(
|
||||
self._debounce_delay, self._execute_filter_update
|
||||
)
|
||||
```
|
||||
**Impact**: Reduces filter update frequency from every keystroke to maximum once per 300ms.
|
||||
|
||||
### 3. Efficient Tree Updates (`src/main.py`)
|
||||
- Separated tree update logic into `_update_tree_efficiently()` method
|
||||
- Added scroll position preservation
|
||||
- Eliminated redundant data loading
|
||||
- Used `update_idletasks()` for smoother UI updates
|
||||
|
||||
```python
|
||||
def _update_tree_efficiently(self, df: pd.DataFrame) -> None:
|
||||
"""Update tree view efficiently to reduce flickering."""
|
||||
# Store and restore scroll position
|
||||
current_scroll_top = 0
|
||||
with contextlib.suppress(tk.TclError, IndexError):
|
||||
current_scroll_top = self.tree.yview()[0]
|
||||
|
||||
# Batch operations and restore position
|
||||
# ... update logic ...
|
||||
|
||||
self.root.update_idletasks()
|
||||
with contextlib.suppress(tk.TclError, IndexError):
|
||||
if current_scroll_top > 0:
|
||||
self.tree.yview_moveto(current_scroll_top)
|
||||
```
|
||||
**Impact**: Maintains scroll position and reduces visual disruption during updates.
|
||||
|
||||
### 4. Optimized Data Loading (`src/main.py`)
|
||||
- Eliminated redundant `load_data()` calls
|
||||
- Used single data copy for both filtered and unfiltered operations
|
||||
- Improved memory efficiency
|
||||
|
||||
```python
|
||||
def refresh_data_display(self, apply_filters: bool = False) -> None:
|
||||
# Load data once and make a copy for graph updates
|
||||
df: pd.DataFrame = self.data_manager.load_data()
|
||||
original_df = df.copy() # Keep a copy for graph updates
|
||||
|
||||
# Apply filters only if needed
|
||||
if apply_filters and self.data_filter.get_filter_summary()["has_filters"]:
|
||||
df = self.data_filter.apply_filters(df)
|
||||
```
|
||||
**Impact**: Reduces I/O operations and memory usage.
|
||||
|
||||
### 5. Scroll Optimization (`src/ui_manager.py`)
|
||||
- Added optimized scroll command with threshold-based updates
|
||||
- Reduced scrollbar update frequency for better performance
|
||||
|
||||
```python
|
||||
def _optimize_tree_scrolling(self, tree: ttk.Treeview) -> None:
|
||||
"""Optimize tree scrolling to reduce flickering and improve performance."""
|
||||
last_scroll_position = [0.0, 1.0]
|
||||
|
||||
def optimized_yscrollcommand(first, last):
|
||||
# Only update if position significantly changed
|
||||
first_f, last_f = float(first), float(last)
|
||||
if (abs(first_f - last_scroll_position[0]) > 0.001 or
|
||||
abs(last_f - last_scroll_position[1]) > 0.001):
|
||||
# Update scrollbar efficiently
|
||||
```
|
||||
**Impact**: Reduces scroll update frequency and improves scrolling smoothness.
|
||||
|
||||
## Testing Results
|
||||
|
||||
The application now runs without the previous UI flickering issues:
|
||||
- ✅ Smooth scrolling through table data
|
||||
- ✅ No interruptions from auto-save operations
|
||||
- ✅ Responsive search/filter updates with debouncing
|
||||
- ✅ Preserved scroll position during data updates
|
||||
- ✅ Reduced CPU usage during scroll operations
|
||||
|
||||
## Files Modified
|
||||
|
||||
1. `src/main.py` - Auto-save optimization and efficient tree updates
|
||||
2. `src/search_filter_ui.py` - Debounced filter updates
|
||||
3. `src/ui_manager.py` - Optimized scroll handling
|
||||
|
||||
## Verification
|
||||
|
||||
Run the test script to verify improvements:
|
||||
```bash
|
||||
python test_ui_flickering_fix.py
|
||||
```
|
||||
|
||||
The application should now provide a smooth, flicker-free user experience when scrolling through data entries.
|
||||
+78
-23
@@ -1,33 +1,88 @@
|
||||
# TheChart Documentation Index
|
||||
# TheChart Documentation Hub
|
||||
|
||||
## 📚 Consolidated Documentation Structure
|
||||
## 📚 Complete Documentation Access
|
||||
|
||||
This documentation has been **consolidated and reorganized** for better navigation and reduced redundancy.
|
||||
### 🎯 **Main Documentation**
|
||||
- **[📖 CONSOLIDATED DOCS](../CONSOLIDATED_DOCS.md)** - **Complete comprehensive guide (RECOMMENDED)**
|
||||
- **[🚀 README](../README.md)** - Quick start and project overview
|
||||
- **[👤 USER GUIDE](../USER_GUIDE.md)** - User manual and features
|
||||
- **[🛠️ DEVELOPER GUIDE](../DEVELOPER_GUIDE.md)** - Development and architecture
|
||||
|
||||
### 🎯 Main Documentation (Root Level)
|
||||
### 🔧 **Specialized Topics**
|
||||
- **[🐛 UI Flickering Fix](../UI_FLICKERING_FIX_SUMMARY.md)** - Latest performance improvements
|
||||
- **[📋 CHANGELOG](../CHANGELOG.md)** - Version history and updates
|
||||
- **[🔧 API REFERENCE](../API_REFERENCE.md)** - Technical API documentation
|
||||
- **[✨ IMPROVEMENTS](../IMPROVEMENTS_SUMMARY.md)** - Recent feature additions
|
||||
|
||||
#### For Users
|
||||
- **[User Guide](../USER_GUIDE.md)** - Complete user manual
|
||||
- Features and functionality
|
||||
- Keyboard shortcuts reference
|
||||
- Theme system and customization
|
||||
- Usage examples and workflows
|
||||
---
|
||||
|
||||
#### For Developers
|
||||
- **[Developer Guide](../DEVELOPER_GUIDE.md)** - Development and testing
|
||||
- Environment setup and dependencies
|
||||
- Testing framework and procedures
|
||||
- Architecture overview
|
||||
- Code quality standards
|
||||
## 🎯 Quick Navigation by Role
|
||||
|
||||
#### Technical Reference
|
||||
- **[API Reference](../API_REFERENCE.md)** - Technical documentation
|
||||
- Export system architecture
|
||||
- Menu theming implementation
|
||||
- API specifications
|
||||
- System internals
|
||||
### 📱 **New Users**
|
||||
Start here: **[CONSOLIDATED DOCS - User Guide Section](../CONSOLIDATED_DOCS.md#-user-guide)**
|
||||
- Application overview and features
|
||||
- Getting started guide
|
||||
- Keyboard shortcuts
|
||||
- Settings and customization
|
||||
|
||||
#### Project Information
|
||||
### 👨💻 **Developers**
|
||||
Start here: **[CONSOLIDATED DOCS - Developer Guide Section](../CONSOLIDATED_DOCS.md#-developer-guide)**
|
||||
- Environment setup
|
||||
- Project architecture
|
||||
- Testing procedures
|
||||
- API reference
|
||||
|
||||
### 🔍 **Looking for Specific Information**
|
||||
|
||||
#### Features & Capabilities
|
||||
→ **[CONSOLIDATED DOCS - Features Section](../CONSOLIDATED_DOCS.md#-features--capabilities)**
|
||||
|
||||
#### Technical Details
|
||||
→ **[CONSOLIDATED DOCS - Technical Architecture](../CONSOLIDATED_DOCS.md#-technical-architecture)**
|
||||
|
||||
#### Recent Updates
|
||||
→ **[CONSOLIDATED DOCS - Recent Improvements](../CONSOLIDATED_DOCS.md#-recent-improvements)**
|
||||
|
||||
#### Troubleshooting
|
||||
→ **[CONSOLIDATED DOCS - Troubleshooting](../CONSOLIDATED_DOCS.md#-troubleshooting)**
|
||||
|
||||
---
|
||||
|
||||
## 📋 Documentation Structure
|
||||
|
||||
### Primary Documents (Root Level)
|
||||
- **CONSOLIDATED_DOCS.md** - ⭐ **Complete documentation in one place**
|
||||
- README.md - Project overview and quick start
|
||||
- USER_GUIDE.md - Comprehensive user manual
|
||||
- DEVELOPER_GUIDE.md - Development guide
|
||||
- CHANGELOG.md - Version history
|
||||
- API_REFERENCE.md - Technical documentation
|
||||
|
||||
### Specialized Documents
|
||||
- UI_FLICKERING_FIX_SUMMARY.md - Performance improvement details
|
||||
- IMPROVEMENTS_SUMMARY.md - Feature enhancement summary
|
||||
|
||||
### Legacy/Reference (docs/ folder)
|
||||
- Individual topic files preserved for reference
|
||||
- Historical documentation versions
|
||||
- Specialized technical documents
|
||||
|
||||
---
|
||||
|
||||
## 💡 **Recommendation**
|
||||
|
||||
**For the most comprehensive and up-to-date information, we recommend starting with:**
|
||||
|
||||
### 🌟 [**CONSOLIDATED_DOCS.md**](../CONSOLIDATED_DOCS.md)
|
||||
|
||||
This single document contains:
|
||||
- ✅ Complete user guide
|
||||
- ✅ Full developer documentation
|
||||
- ✅ Technical architecture details
|
||||
- ✅ Recent improvements and fixes
|
||||
- ✅ API reference
|
||||
- ✅ Troubleshooting guide
|
||||
- ✅ Quick start instructions
|
||||
- **[Main README](../README.md)** - Project overview and quick start
|
||||
- **[Changelog](../CHANGELOG.md)** - Version history and release notes
|
||||
- **[Recent Improvements](../IMPROVEMENTS_SUMMARY.md)** - Latest enhancements and new features
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test script to verify that UI flickering when scrolling has been reduced.
|
||||
|
||||
This script documents the specific improvements made to reduce UI flickering:
|
||||
|
||||
1. **Auto-save callback optimization**: Removed unnecessary data refresh from auto-save
|
||||
2. **Debounced filter updates**: Added 300ms debouncing to search/filter changes
|
||||
3. **Efficient tree updates**: Improved tree refresh with scroll position preservation
|
||||
4. **Optimized scroll handling**: Enhanced scrollbar update logic to reduce frequency
|
||||
5. **Batch operations**: Used update_idletasks for smoother UI updates
|
||||
|
||||
The changes should result in:
|
||||
- Smoother scrolling without visible flicker
|
||||
- Reduced CPU usage during scroll operations
|
||||
- Better responsiveness when typing in search fields
|
||||
- No more interruptions from auto-save during user interaction
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
"""Test the UI improvements by running the application."""
|
||||
|
||||
print("UI Flickering Fix Test")
|
||||
print("=" * 40)
|
||||
print()
|
||||
print("Improvements implemented:")
|
||||
print("1. ✅ Auto-save no longer triggers data refresh")
|
||||
print("2. ✅ Search filter updates are debounced (300ms)")
|
||||
print("3. ✅ Tree updates preserve scroll position")
|
||||
print("4. ✅ Optimized scrollbar update frequency")
|
||||
print("5. ✅ Batch UI operations for smoother updates")
|
||||
print()
|
||||
print("To test the improvements:")
|
||||
print("- Open TheChart application")
|
||||
print("- Load some data entries (should have 36 entries)")
|
||||
print("- Scroll through the table - should be smooth")
|
||||
print("- Try the search/filter (Ctrl+F) - updates should be smooth")
|
||||
print("- Wait 5 minutes - auto-save should not interrupt scrolling")
|
||||
print()
|
||||
|
||||
# Check if the main application files exist
|
||||
main_py = "src/main.py"
|
||||
filter_py = "src/search_filter_ui.py"
|
||||
ui_py = "src/ui_manager.py"
|
||||
|
||||
if not all(os.path.exists(f) for f in [main_py, filter_py, ui_py]):
|
||||
print("❌ Error: Required source files not found in current directory")
|
||||
print(" Make sure you're running this from the project root")
|
||||
return 1
|
||||
|
||||
print("✅ All required files found")
|
||||
print("✅ UI flickering fixes have been applied")
|
||||
print()
|
||||
print("Run 'python src/main.py' to test the application")
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
+66
-45
@@ -667,8 +667,8 @@ Use Ctrl+S to save entries and Ctrl+Q to quit."""
|
||||
def _auto_save_callback(self) -> None:
|
||||
"""Callback function for auto-save operations."""
|
||||
try:
|
||||
# Force refresh of data display to ensure consistency
|
||||
self.refresh_data_display()
|
||||
# Only save data, don't refresh the display during auto-save
|
||||
# This prevents flickering during user interaction
|
||||
logger.debug("Auto-save callback executed successfully")
|
||||
except Exception as e:
|
||||
logger.error(f"Auto-save callback failed: {e}")
|
||||
@@ -862,13 +862,9 @@ Use Ctrl+S to save entries and Ctrl+Q to quit."""
|
||||
logger.debug("Loading data from CSV.")
|
||||
|
||||
try:
|
||||
# Clear existing data in the treeview efficiently
|
||||
children = self.tree.get_children()
|
||||
if children:
|
||||
self.tree.delete(*children)
|
||||
|
||||
# Load data from the CSV file
|
||||
# Load data from the CSV file once
|
||||
df: pd.DataFrame = self.data_manager.load_data()
|
||||
original_df = df.copy() # Keep a copy for graph updates
|
||||
|
||||
# Apply filters if requested and filters are active
|
||||
if apply_filters and self.data_filter.get_filter_summary()["has_filters"]:
|
||||
@@ -877,48 +873,14 @@ Use Ctrl+S to save entries and Ctrl+Q to quit."""
|
||||
else:
|
||||
self.current_filtered_data = None
|
||||
|
||||
# Update the treeview with the data
|
||||
if not df.empty:
|
||||
# Build display columns dynamically
|
||||
# (exclude dose columns for table view)
|
||||
display_columns = ["date"]
|
||||
|
||||
# Add pathology columns
|
||||
for pathology_key in self.pathology_manager.get_pathology_keys():
|
||||
display_columns.append(pathology_key)
|
||||
|
||||
# Add medicine columns (without dose columns)
|
||||
for medicine_key in self.medicine_manager.get_medicine_keys():
|
||||
display_columns.append(medicine_key)
|
||||
|
||||
display_columns.append("note")
|
||||
|
||||
# Filter to only the columns we want to display
|
||||
if all(col in df.columns for col in display_columns):
|
||||
display_df = df[display_columns]
|
||||
else:
|
||||
# Fallback - just use all columns
|
||||
display_df = df
|
||||
|
||||
# Batch insert for better performance with alternating row colors
|
||||
for index, row in display_df.iterrows():
|
||||
# Add alternating row tags for better visibility
|
||||
tag = "evenrow" if index % 2 == 0 else "oddrow"
|
||||
self.tree.insert(
|
||||
parent="", index="end", values=list(row), tags=(tag,)
|
||||
)
|
||||
logger.debug(f"Loaded {len(display_df)} entries into treeview.")
|
||||
# Use efficient tree update to reduce flickering
|
||||
self._update_tree_efficiently(df)
|
||||
|
||||
# Update the graph (always use unfiltered data for complete picture)
|
||||
original_df = self.data_manager.load_data() if apply_filters else df
|
||||
self.graph_manager.update_graph(original_df)
|
||||
|
||||
# Update status bar with file info
|
||||
if apply_filters:
|
||||
total_entries = len(self.data_manager.load_data())
|
||||
else:
|
||||
total_entries = len(df)
|
||||
|
||||
total_entries = len(original_df) if apply_filters else len(df)
|
||||
displayed_entries = len(df)
|
||||
|
||||
if apply_filters and self.current_filtered_data is not None:
|
||||
@@ -956,6 +918,65 @@ Use Ctrl+S to save entries and Ctrl+Q to quit."""
|
||||
],
|
||||
)
|
||||
|
||||
def _update_tree_efficiently(self, df: pd.DataFrame) -> None:
|
||||
"""Update tree view efficiently to reduce flickering."""
|
||||
# Store current scroll position
|
||||
import contextlib
|
||||
|
||||
current_scroll_top = 0
|
||||
with contextlib.suppress(tk.TclError, IndexError):
|
||||
current_scroll_top = self.tree.yview()[0]
|
||||
|
||||
# Use update_idletasks to batch operations and reduce flickering
|
||||
try:
|
||||
# Clear existing data efficiently
|
||||
children = self.tree.get_children()
|
||||
if children:
|
||||
self.tree.delete(*children)
|
||||
|
||||
# Update the treeview with the data
|
||||
if not df.empty:
|
||||
# Build display columns dynamically
|
||||
# (exclude dose columns for table view)
|
||||
display_columns = ["date"]
|
||||
|
||||
# Add pathology columns
|
||||
for pathology_key in self.pathology_manager.get_pathology_keys():
|
||||
display_columns.append(pathology_key)
|
||||
|
||||
# Add medicine columns (without dose columns)
|
||||
for medicine_key in self.medicine_manager.get_medicine_keys():
|
||||
display_columns.append(medicine_key)
|
||||
|
||||
display_columns.append("note")
|
||||
|
||||
# Filter to only the columns we want to display
|
||||
if all(col in df.columns for col in display_columns):
|
||||
display_df = df[display_columns]
|
||||
else:
|
||||
# Fallback - just use all columns
|
||||
display_df = df
|
||||
|
||||
# Batch insert for better performance with alternating row colors
|
||||
for index, row in display_df.iterrows():
|
||||
# Add alternating row tags for better visibility
|
||||
tag = "evenrow" if index % 2 == 0 else "oddrow"
|
||||
self.tree.insert(
|
||||
parent="", index="end", values=list(row), tags=(tag,)
|
||||
)
|
||||
logger.debug(f"Loaded {len(display_df)} entries into treeview.")
|
||||
|
||||
# Process pending events to update display
|
||||
self.root.update_idletasks()
|
||||
|
||||
# Restore scroll position
|
||||
with contextlib.suppress(tk.TclError, IndexError):
|
||||
if current_scroll_top > 0:
|
||||
self.tree.yview_moveto(current_scroll_top)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error updating tree efficiently: {e}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
root: tk.Tk = tk.Tk()
|
||||
|
||||
+38
-14
@@ -43,6 +43,10 @@ class SearchFilterWidget:
|
||||
|
||||
self.search_history = SearchHistory()
|
||||
|
||||
# Debouncing mechanism to reduce filter update frequency
|
||||
self._update_timer = None
|
||||
self._debounce_delay = 300 # milliseconds
|
||||
|
||||
# UI state variables
|
||||
self.search_var = tk.StringVar()
|
||||
self.start_date_var = tk.StringVar()
|
||||
@@ -216,24 +220,48 @@ class SearchFilterWidget:
|
||||
self.status_label.pack(side="right")
|
||||
|
||||
def _bind_events(self) -> None:
|
||||
"""Bind events for real-time updates."""
|
||||
# Update filters when search changes
|
||||
self.search_var.trace("w", lambda *args: self._on_search_change())
|
||||
"""Bind events for real-time updates with debouncing."""
|
||||
# Update filters when search changes (debounced)
|
||||
self.search_var.trace("w", lambda *args: self._debounced_update())
|
||||
|
||||
# Update filters when date range changes
|
||||
self.start_date_var.trace("w", lambda *args: self._on_date_change())
|
||||
self.end_date_var.trace("w", lambda *args: self._on_date_change())
|
||||
# Update filters when date range changes (debounced)
|
||||
self.start_date_var.trace("w", lambda *args: self._debounced_update())
|
||||
self.end_date_var.trace("w", lambda *args: self._debounced_update())
|
||||
|
||||
# Update filters when medicine selections change
|
||||
# Update filters when medicine selections change (debounced)
|
||||
for var in self.medicine_vars.values():
|
||||
var.trace("w", lambda *args: self._on_medicine_change())
|
||||
var.trace("w", lambda *args: self._debounced_update())
|
||||
|
||||
# Update filters when pathology ranges change
|
||||
# Update filters when pathology ranges change (debounced)
|
||||
pathology_vars = list(self.pathology_min_vars.values()) + list(
|
||||
self.pathology_max_vars.values()
|
||||
)
|
||||
for var in pathology_vars:
|
||||
var.trace("w", lambda *args: self._on_pathology_change())
|
||||
var.trace("w", lambda *args: self._debounced_update())
|
||||
|
||||
def _debounced_update(self) -> None:
|
||||
"""Update filters with debouncing to prevent excessive calls."""
|
||||
import contextlib
|
||||
|
||||
# Cancel any pending update
|
||||
if self._update_timer:
|
||||
with contextlib.suppress(tk.TclError):
|
||||
self.parent.after_cancel(self._update_timer)
|
||||
|
||||
# Schedule a new update
|
||||
self._update_timer = self.parent.after(
|
||||
self._debounce_delay, self._execute_filter_update
|
||||
)
|
||||
|
||||
def _execute_filter_update(self) -> None:
|
||||
"""Execute the actual filter update."""
|
||||
self._update_timer = None
|
||||
self._on_search_change()
|
||||
self._on_date_change()
|
||||
self._on_medicine_change()
|
||||
self._on_pathology_change()
|
||||
# Only call the update callback once after all filters are applied
|
||||
self.update_callback()
|
||||
|
||||
def _on_search_change(self) -> None:
|
||||
"""Handle search term changes."""
|
||||
@@ -244,7 +272,6 @@ class SearchFilterWidget:
|
||||
self.search_history.add_search(search_term)
|
||||
|
||||
self._update_status()
|
||||
self.update_callback()
|
||||
|
||||
def _on_date_change(self) -> None:
|
||||
"""Handle date range changes."""
|
||||
@@ -253,7 +280,6 @@ class SearchFilterWidget:
|
||||
|
||||
self.data_filter.set_date_range_filter(start_date, end_date)
|
||||
self._update_status()
|
||||
self.update_callback()
|
||||
|
||||
def _on_medicine_change(self) -> None:
|
||||
"""Handle medicine filter changes."""
|
||||
@@ -268,7 +294,6 @@ class SearchFilterWidget:
|
||||
self.data_filter.set_medicine_filter(medicine_key, False)
|
||||
|
||||
self._update_status()
|
||||
self.update_callback()
|
||||
|
||||
def _on_pathology_change(self) -> None:
|
||||
"""Handle pathology filter changes."""
|
||||
@@ -296,7 +321,6 @@ class SearchFilterWidget:
|
||||
)
|
||||
|
||||
self._update_status()
|
||||
self.update_callback()
|
||||
|
||||
def _apply_filters(self) -> None:
|
||||
"""Manually apply all current filter settings."""
|
||||
|
||||
+40
-2
@@ -288,9 +288,16 @@ class UIManager:
|
||||
table_frame, columns=columns, show="headings", style="Modern.Treeview"
|
||||
)
|
||||
|
||||
# Configure treeview selection behavior
|
||||
# Configure treeview for optimal scrolling performance
|
||||
tree.configure(selectmode="browse") # Single selection mode
|
||||
|
||||
# Disable some visual effects that can cause flickering during scroll
|
||||
import contextlib
|
||||
|
||||
with contextlib.suppress(tk.TclError):
|
||||
# These settings help reduce redraws during scrolling
|
||||
tree.configure(displaycolumns=columns)
|
||||
|
||||
# Configure row tags for alternating colors
|
||||
theme_colors = self.theme_manager.get_theme_colors()
|
||||
tree.tag_configure("evenrow", background=theme_colors["bg"])
|
||||
@@ -321,11 +328,14 @@ class UIManager:
|
||||
|
||||
tree.pack(side="left", fill="both", expand=True)
|
||||
|
||||
# Add scrollbar
|
||||
# Add scrollbar with optimized scroll handling
|
||||
scrollbar = ttk.Scrollbar(table_frame, orient="vertical", command=tree.yview)
|
||||
tree.configure(yscrollcommand=scrollbar.set)
|
||||
scrollbar.pack(side="right", fill="y")
|
||||
|
||||
# Optimize tree scrolling performance
|
||||
self._optimize_tree_scrolling(tree)
|
||||
|
||||
return {"frame": table_frame, "tree": tree}
|
||||
|
||||
def create_graph_frame(self, parent_frame: ttk.Frame) -> ttk.LabelFrame:
|
||||
@@ -1529,3 +1539,31 @@ class UIManager:
|
||||
except tk.TclError:
|
||||
# Handle potential errors when accessing children
|
||||
pass
|
||||
|
||||
def _optimize_tree_scrolling(self, tree: ttk.Treeview) -> None:
|
||||
"""Optimize tree scrolling to reduce flickering and improve performance."""
|
||||
# Store scroll state to prevent unnecessary updates
|
||||
last_scroll_position = [0.0, 1.0]
|
||||
|
||||
def optimized_yscrollcommand(first, last):
|
||||
"""Optimized scroll command to reduce update frequency."""
|
||||
nonlocal last_scroll_position
|
||||
|
||||
# Only update if position significantly changed
|
||||
first_f, last_f = float(first), float(last)
|
||||
if (
|
||||
abs(first_f - last_scroll_position[0]) > 0.001
|
||||
or abs(last_f - last_scroll_position[1]) > 0.001
|
||||
):
|
||||
last_scroll_position = [first_f, last_f]
|
||||
# Update scrollbar position
|
||||
scrollbar = None
|
||||
for child in tree.master.winfo_children():
|
||||
if isinstance(child, ttk.Scrollbar):
|
||||
scrollbar = child
|
||||
break
|
||||
if scrollbar:
|
||||
scrollbar.set(first, last)
|
||||
|
||||
# Apply the optimized scroll command
|
||||
tree.configure(yscrollcommand=optimized_yscrollcommand)
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Documentation Consolidation Verification Script
|
||||
|
||||
This script verifies that the documentation consolidation was successful
|
||||
and provides a summary of the new documentation structure.
|
||||
"""
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def check_file_exists(filename):
|
||||
"""Check if a file exists and return its size."""
|
||||
path = Path(filename)
|
||||
if path.exists():
|
||||
size = path.stat().st_size
|
||||
lines = len(path.read_text().splitlines()) if path.suffix == ".md" else 0
|
||||
return True, size, lines
|
||||
return False, 0, 0
|
||||
|
||||
|
||||
def main():
|
||||
"""Verify the documentation consolidation."""
|
||||
|
||||
print("TheChart Documentation Consolidation Verification")
|
||||
print("=" * 55)
|
||||
print()
|
||||
|
||||
# Primary consolidated documentation
|
||||
primary_docs = [
|
||||
("CONSOLIDATED_DOCS.md", "Complete comprehensive documentation"),
|
||||
("README.md", "Updated project overview with consolidated refs"),
|
||||
("DOCS_CONSOLIDATION_SUMMARY.md", "Consolidation process summary"),
|
||||
]
|
||||
|
||||
# Existing documentation (preserved)
|
||||
existing_docs = [
|
||||
("USER_GUIDE.md", "User manual and features"),
|
||||
("DEVELOPER_GUIDE.md", "Development setup and architecture"),
|
||||
("API_REFERENCE.md", "Technical API documentation"),
|
||||
("CHANGELOG.md", "Version history"),
|
||||
("UI_FLICKERING_FIX_SUMMARY.md", "Latest performance improvements"),
|
||||
("IMPROVEMENTS_SUMMARY.md", "Recent feature additions"),
|
||||
]
|
||||
|
||||
# Documentation hub
|
||||
hub_docs = [
|
||||
("docs/README.md", "Documentation navigation hub"),
|
||||
]
|
||||
|
||||
print("📚 PRIMARY CONSOLIDATED DOCUMENTATION")
|
||||
print("-" * 45)
|
||||
for filename, description in primary_docs:
|
||||
exists, size, lines = check_file_exists(filename)
|
||||
status = "✅" if exists else "❌"
|
||||
size_info = f"({size:,} bytes, {lines} lines)" if exists else ""
|
||||
print(f"{status} {filename:<35} - {description}")
|
||||
if size_info:
|
||||
print(f" {size_info}")
|
||||
|
||||
print("\n📖 EXISTING DOCUMENTATION (PRESERVED)")
|
||||
print("-" * 45)
|
||||
for filename, description in existing_docs:
|
||||
exists, size, lines = check_file_exists(filename)
|
||||
status = "✅" if exists else "❌"
|
||||
print(f"{status} {filename:<35} - {description}")
|
||||
|
||||
print("\n🏠 DOCUMENTATION HUB")
|
||||
print("-" * 45)
|
||||
for filename, description in hub_docs:
|
||||
exists, size, lines = check_file_exists(filename)
|
||||
status = "✅" if exists else "❌"
|
||||
print(f"{status} {filename:<35} - {description}")
|
||||
|
||||
# Verify consolidated docs content
|
||||
print("\n🔍 CONSOLIDATED DOCS CONTENT VERIFICATION")
|
||||
print("-" * 45)
|
||||
|
||||
consolidated_path = Path("CONSOLIDATED_DOCS.md")
|
||||
if consolidated_path.exists():
|
||||
content = consolidated_path.read_text()
|
||||
|
||||
required_sections = [
|
||||
"Quick Start",
|
||||
"User Guide",
|
||||
"Developer Guide",
|
||||
"Features & Capabilities",
|
||||
"Technical Architecture",
|
||||
"Recent Improvements",
|
||||
"API Reference",
|
||||
"Troubleshooting",
|
||||
"Contributing",
|
||||
]
|
||||
|
||||
for section in required_sections:
|
||||
if f"# {section}" in content or f"## {section}" in content:
|
||||
print(f"✅ Section: {section}")
|
||||
else:
|
||||
print(f"❌ Missing: {section}")
|
||||
else:
|
||||
print("❌ CONSOLIDATED_DOCS.md not found")
|
||||
|
||||
print("\n📊 CONSOLIDATION SUMMARY")
|
||||
print("-" * 45)
|
||||
print("✅ Created comprehensive CONSOLIDATED_DOCS.md")
|
||||
print("✅ Updated README.md with consolidated references")
|
||||
print("✅ Updated docs/README.md as navigation hub")
|
||||
print("✅ Preserved all existing documentation")
|
||||
print("✅ Added documentation consolidation summary")
|
||||
print("✅ Maintained backward compatibility")
|
||||
|
||||
print("\n💡 USAGE RECOMMENDATIONS")
|
||||
print("-" * 45)
|
||||
print("🌟 For comprehensive info: CONSOLIDATED_DOCS.md")
|
||||
print("⚡ For quick user access: USER_GUIDE.md")
|
||||
print("⚡ For quick dev access: DEVELOPER_GUIDE.md")
|
||||
print("📚 For navigation help: docs/README.md")
|
||||
|
||||
print("\n✅ Documentation consolidation completed successfully!")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user