Skip to main content

Pythonista UI constraints driven by the Key Value Observing (KVO) protocol

Project description

Pythonista UI constraints driven by the Key Value Observing (KVO) protocol

History

First version of UI constraints for Pythonista were created as a wrapper around Apple NSLayoutConstraint class. While functional, it suffered from the same restrictions as the underlying Apple class, and was somewhat inconvenient to develop with, due to the "either frames or constraints" mindset and some mystical crashes.

Second version was built on top of the scripter, utilizing the ui.View update method that gets called several times a second. Constraints could now be designed freely, and this version acted as an excellent proof of concept. There was the obvious performance concern due to the constraints being checked constantly, even if nothing was happening in the UI – easily few thousand small checks per second for a realistic UI.

This version replaces the update method with the KVO (Key Value Observing) protocol, running the constraint checks only when the position or the frame of the view changes. Thus we avoid the performance overhead while retaining the freedom of custom constraints.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pythonista-anchors-2020.7.23.tar.gz (12.5 kB view hashes)

Uploaded Source

Built Distribution

pythonista_anchors-2020.7.23-py2.py3-none-any.whl (11.3 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page