feat: Add test script for mouse wheel scrolling functionality in entry and edit windows
Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled
Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled
This commit is contained in:
115
test_scrolling.py
Normal file
115
test_scrolling.py
Normal file
@@ -0,0 +1,115 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test script to verify mouse wheel scrolling works in both the new entry window
|
||||
and edit window of TheChart application.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import tkinter as tk
|
||||
|
||||
from src.ui_manager import UIManager
|
||||
|
||||
|
||||
def test_scrolling():
|
||||
"""Test both new entry and edit window scrolling."""
|
||||
print("Testing mouse wheel scrolling functionality...")
|
||||
|
||||
# Create test root window
|
||||
root = tk.Tk()
|
||||
root.title("Scrolling Test")
|
||||
root.geometry("800x600")
|
||||
|
||||
# Create logger
|
||||
logger = logging.getLogger("test")
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
# Create UI manager
|
||||
ui_manager = UIManager(root, logger)
|
||||
|
||||
# Create main frame
|
||||
main_frame = tk.Frame(root)
|
||||
main_frame.pack(fill="both", expand=True)
|
||||
main_frame.grid_rowconfigure(0, weight=1)
|
||||
main_frame.grid_rowconfigure(1, weight=1)
|
||||
main_frame.grid_columnconfigure(0, weight=1)
|
||||
main_frame.grid_columnconfigure(1, weight=1)
|
||||
|
||||
# Test 1: Create input frame (new entry window)
|
||||
print("✓ Creating new entry input frame with mouse wheel scrolling...")
|
||||
ui_manager.create_input_frame(main_frame)
|
||||
|
||||
# Test 2: Create edit window
|
||||
def test_edit_window():
|
||||
print("✓ Creating edit window with mouse wheel scrolling...")
|
||||
# Sample data for edit window
|
||||
test_values = (
|
||||
"01/15/2025", # date
|
||||
"3", # depression
|
||||
"5", # anxiety
|
||||
"7", # sleep
|
||||
"4", # appetite
|
||||
"1", # bupropion
|
||||
"09:00: 150", # bup_doses
|
||||
"0", # hydroxyzine
|
||||
"", # hydro_doses
|
||||
"1", # gabapentin
|
||||
"20:00: 100", # gaba_doses
|
||||
"0", # propranolol
|
||||
"", # prop_doses
|
||||
"0", # quetiapine
|
||||
"", # quet_doses
|
||||
"Test note", # note
|
||||
)
|
||||
|
||||
callbacks = {
|
||||
"save": lambda *args: print("Save callback called"),
|
||||
"delete": lambda *args: print("Delete callback called"),
|
||||
}
|
||||
|
||||
edit_window = ui_manager.create_edit_window(test_values, callbacks)
|
||||
return edit_window
|
||||
|
||||
# Add test button
|
||||
test_button = tk.Button(
|
||||
main_frame,
|
||||
text="Test Edit Window Scrolling",
|
||||
command=test_edit_window,
|
||||
font=("TkDefaultFont", 12),
|
||||
bg="#4CAF50",
|
||||
fg="white",
|
||||
padx=20,
|
||||
pady=10,
|
||||
)
|
||||
test_button.grid(row=2, column=0, columnspan=2, pady=20)
|
||||
|
||||
# Add instructions
|
||||
instructions = tk.Label(
|
||||
main_frame,
|
||||
text="Instructions:\n\n"
|
||||
"1. Use mouse wheel anywhere in the 'New Entry' section to test scrolling\n"
|
||||
"2. Click 'Test Edit Window Scrolling' button\n"
|
||||
"3. Use mouse wheel anywhere in the edit window to test scrolling\n"
|
||||
"4. Both windows should scroll smoothly with mouse wheel\n\n"
|
||||
"✓ Mouse wheel scrolling has been enhanced for both windows!",
|
||||
font=("TkDefaultFont", 10),
|
||||
justify="left",
|
||||
bg="#E8F5E8",
|
||||
padx=20,
|
||||
pady=15,
|
||||
)
|
||||
instructions.grid(row=3, column=0, columnspan=2, padx=20, pady=10, sticky="ew")
|
||||
|
||||
print("✓ Test setup complete!")
|
||||
print("\nMouse wheel scrolling features implemented:")
|
||||
print(" • Recursive binding to all child widgets")
|
||||
print(" • Platform-specific event handling (Windows/Linux)")
|
||||
print(" • Focus management for consistent scrolling")
|
||||
print(" • Works anywhere within the scrollable areas")
|
||||
print("\nTest the scrolling by moving your mouse wheel over any part of the")
|
||||
print("'New Entry' section or the edit window when opened.")
|
||||
|
||||
root.mainloop()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_scrolling()
|
||||
Reference in New Issue
Block a user