Implement a context manager as a property locking mechanism in Widget.