You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Toga provides a list of built-in widgets; however, we hope to develop an ecosystem of third-party widgets.
Built-in widgets are able to from toga import SomeWidget, and the implementation of SomeWidget can call self.factory.SomeWidget() to instantiate a platform-specific implementation.
However, if a third-party widget requires a native implementation (e.g., a Cocoa wrapper, a Winforms wrapper etc), there's not currently any way to use that infrastructure to get a platform-specific implementation.
Describe the solution you'd like
It should be possible for a third-party package to define a widget that has platform-specific implementations.
Entry points should exist, both for defining the existence of a widget, and for registering platform-specific implementations of that widget. This way, installing a third-party widget package would make that widget available in the toga. namespace (or maybe in a toga.ext. extension namespace to prevent naming collisions), and third-party widgets could invoke self.factory.CustomWidget() to get the appropriate platform implementation.
In the best case, Toga would "eat its own dogfood", and use the same mechanisms for built-in widgets that third party widgets use.
Describe alternatives you've considered
If the entry-point approach is used, it may not be necessary to register the widgets, just the implementations. Requiring end users to say from toga_thirdparty import CustomWidget isn't unreasonable; the primary concern is that the implementation of CustomWidget needs to be able to invoke self.factory.CustomWidget() (or self.factory.toga_thirdparty.CustomWidget(), to ensure namespacing) to get a platform-specific implementation of the widget).
As an alternative to entry points, Toga's widget factory could include a mechanism for third-party widgets to register themselves on import. The end result is much the same; the only difference is where the registration process occurs.
Additional context
This has been a long-standing need, but came up recently in the context of #2927.
We're already using entry points to register backends; the interface that toga cocoa uses to register itself with toga core is accessible to third parties. Extending this to include widgets (or other platform-specific features) would make sense.
This should be accompanied by documentation that provides a "sample" third-party widget. This documentation should also encourage users to use the togax namespace, rather than the toga namespace for third-party widgets registered on PyPI.
The text was updated successfully, but these errors were encountered:
What is the problem or limitation you are having?
Toga provides a list of built-in widgets; however, we hope to develop an ecosystem of third-party widgets.
Built-in widgets are able to
from toga import SomeWidget
, and the implementation ofSomeWidget
can callself.factory.SomeWidget()
to instantiate a platform-specific implementation.However, if a third-party widget requires a native implementation (e.g., a Cocoa wrapper, a Winforms wrapper etc), there's not currently any way to use that infrastructure to get a platform-specific implementation.
Describe the solution you'd like
It should be possible for a third-party package to define a widget that has platform-specific implementations.
Entry points should exist, both for defining the existence of a widget, and for registering platform-specific implementations of that widget. This way, installing a third-party widget package would make that widget available in the
toga.
namespace (or maybe in atoga.ext.
extension namespace to prevent naming collisions), and third-party widgets could invokeself.factory.CustomWidget()
to get the appropriate platform implementation.In the best case, Toga would "eat its own dogfood", and use the same mechanisms for built-in widgets that third party widgets use.
Describe alternatives you've considered
If the entry-point approach is used, it may not be necessary to register the widgets, just the implementations. Requiring end users to say
from toga_thirdparty import CustomWidget
isn't unreasonable; the primary concern is that the implementation ofCustomWidget
needs to be able to invokeself.factory.CustomWidget()
(orself.factory.toga_thirdparty.CustomWidget()
, to ensure namespacing) to get a platform-specific implementation of the widget).As an alternative to entry points, Toga's widget factory could include a mechanism for third-party widgets to register themselves on import. The end result is much the same; the only difference is where the registration process occurs.
Additional context
This has been a long-standing need, but came up recently in the context of #2927.
We're already using entry points to register backends; the interface that toga cocoa uses to register itself with toga core is accessible to third parties. Extending this to include widgets (or other platform-specific features) would make sense.
This should be accompanied by documentation that provides a "sample" third-party widget. This documentation should also encourage users to use the
togax
namespace, rather than thetoga
namespace for third-party widgets registered on PyPI.The text was updated successfully, but these errors were encountered: