Python API improvements: Vectors, bounds, window singleton, hidden types
- #177: GridPoint.grid_pos property returns (x, y) tuple - #179: Grid.grid_size returns Vector instead of tuple - #181: Grid.center returns Vector instead of tuple - #182: Caption.size/w/h read-only properties for text dimensions - #184: mcrfpy.window singleton for window access - #185: Removed get_bounds() method, use .bounds property instead - #188: bounds/global_bounds return (pos, size) as pair of Vectors - #189: Hide internal types from module namespace (iterators, collections) Also fixed critical bug: Changed static PyTypeObject to inline in headers to ensure single instance across translation units (was causing segfaults). Closes #177, closes #179, closes #181, closes #182, closes #184, closes #185, closes #188, closes #189 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
c6233fa47f
commit
f9b6cdef1c
17 changed files with 448 additions and 87 deletions
43
tests/test_frame_bounds.py
Normal file
43
tests/test_frame_bounds.py
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Test Frame bounds"""
|
||||
import sys
|
||||
import mcrfpy
|
||||
|
||||
print("Testing Frame bounds...")
|
||||
frame = mcrfpy.Frame(pos=(50, 100), size=(200, 150))
|
||||
|
||||
print(f"Frame created: {frame}")
|
||||
|
||||
# Test bounds returns tuple of Vectors
|
||||
bounds = frame.bounds
|
||||
print(f"bounds type: {type(bounds)}")
|
||||
print(f"bounds value: {bounds}")
|
||||
|
||||
if not isinstance(bounds, tuple):
|
||||
print(f"FAIL: bounds should be tuple, got {type(bounds)}")
|
||||
sys.exit(1)
|
||||
|
||||
if len(bounds) != 2:
|
||||
print(f"FAIL: bounds should have 2 elements, got {len(bounds)}")
|
||||
sys.exit(1)
|
||||
|
||||
pos, size = bounds
|
||||
print(f"pos type: {type(pos)}, value: {pos}")
|
||||
print(f"size type: {type(size)}, value: {size}")
|
||||
|
||||
if not hasattr(pos, 'x'):
|
||||
print(f"FAIL: pos should be Vector (has no .x), got {type(pos)}")
|
||||
sys.exit(1)
|
||||
|
||||
print(f"pos.x={pos.x}, pos.y={pos.y}")
|
||||
print(f"size.x={size.x}, size.y={size.y}")
|
||||
|
||||
# Test get_bounds() method is removed (#185)
|
||||
if hasattr(frame, 'get_bounds'):
|
||||
print("FAIL: get_bounds() method should be removed")
|
||||
sys.exit(1)
|
||||
else:
|
||||
print("PASS: get_bounds() method is removed")
|
||||
|
||||
print("PASS: Frame bounds test passed!")
|
||||
sys.exit(0)
|
||||
Loading…
Add table
Add a link
Reference in a new issue