Widget API uniformisation [breaking changes ahead] #1521
Replies: 2 comments 4 replies
-
Generally speaking, I agree consistency in APIs is something we should be aiming for; and these suggestions pretty much all point in the right direction. One of the things that has been causing me to hold off making 0.3 final has been nailing down API inconsistencies like these, so thanks for the prompt to take a closer look at this problem. PRs (or tickets describing the nature of the change) would all be welcome, within the caveats listed below. For backwards compatibility, any naming change should preserve the existing API, logging a deprecation warning if the old API is used, and clearly marking out pieces of code that can be purged when the time comes to remove the backwards compatibility shim. Some specific comments: Initial valueI agree that There is a very subtle difference with Similarly, some widgets have a Button and label textI agree that Switch
|
Beta Was this translation helpful? Give feedback.
-
So these are done. But it turns out I wasn't as thorough as I though. There is one more renaming that could be done. Command and OptionItem both have That's it. What do you think? I feel a bit pedantic even suggesting it. But still. |
Beta Was this translation helpful? Give feedback.
-
I did a sweep through all the widgets to try to find inconsistencies. This is what I found. I know a lot of my suggestions boil down to personal preference, but I hope this make sense to more people.
"initial value" constructor parameter
The name of the constructor parameter to set an initial value is not uniform. Some use
initial
, othersdefault
, Switch usesis_on
. I would expect this parameter to be calledvalue
, like the property (except maybe Switch; more below).Widgets: TextInput, PasswordInput, NumberInput, MultilineTextInput, Slider, DatePicker, TimePicker, Switch
Button and Label text
It's
Button.label
andLabel.text
. I would suggest they should both betext
Switch
This widget is an oddball.
The value property is called
is_on
instead ofvalue
. It feels wrong for another reason: instinctively, I expect a property prefixed byis_
to be read-only.The change event is called
on_toggle
. It should beon_change
.Beta Was this translation helpful? Give feedback.
All reactions