Understand Toga's Three-Layer Architecture
mainToga widgets are composed of three distinct internal layers. Understanding these layers helps in understanding how Toga abstracts platform-specific complexities into a single, consistent API.
- Interface Layer: The public API defined in
toga-core. This is what you use to build your application. It handles input validation, persistent value storage, and style/layout attributes. - Implementation Layer: The platform-specific representation (e.g.,
toga-cocoafor macOS,toga-gtkfor Linux). It provides a private utility API to the Interface layer. Every interface widget has exactly one implementation widget, though not all interface widgets are available on all platforms. - Native Layer: The actual system widgets provided by the underlying toolkit (e.g.,
Gtk.Button). An implementation might use a single native widget or multiple native widgets combined into a single "primary" native widget to satisfy the Toga interface.