pyface
pyface copied to clipboard
The _create method should be public
The base Widget._create
method is nominally private, but in practice tends to get used as:
w = Widget(parent=parent)
w._create()
although a few widgets perform the _create()
call as part of their __init__
.
Two-phase creation has an advantage in that it permits programmatic configuration of the widget beyond what is passed in at class creation time before the underlying toolkit control is created.
This issue proposes that:
- [x] there is a public
create
method, which initially can be implemented to simple call_create
(#735) - [x] that calls to
_create
are changed to calls tocreate
- [x] that classes migrate the implementation of
_create
intocreate
, and make_create
callcreate
- [ ] that
_create
is removed
Additionally:
- [x] any classes which call
_create
or (worse)_create_control
in their__init__
be modified to not do that - [ ] classes in Tasks which match the new
IWidget
interface (such asITaskPane
) should be modified to inherit fromIWidget
and their implementations to inherit fromWidget
.
Strategy for removing create
calls from __init__
:
- [x] initially:
- add a keyword-only argument
create
which defaults toTrue
initially (sincecreate
is a method name it will never conflict with a trait name) - if
create
isTrue
then call thecreate
method, but also issue aPendingDeprecationWarning
- add a keyword-only argument
- [ ] in the next a major release:
- ignore the
create
argument other than indicate that it is deprecated if it is passed
- ignore the
- [ ] at some later release, remove any handling for
create
(ideally, removing the entire__init__
method).
I've added this to the 8.0 release - the next few steps in this should be done for that release, if time permits.
It will not be completed in the 8.0 release, however.
Incremental progress in the 8.0 release, the rest pushed to 9.0