typemytype / drawbot

http://www.drawbot.com
Other
408 stars 63 forks source link

improve support for "Apply/Build/Update" button in Variable #383

Closed typemytype closed 4 years ago

typemytype commented 4 years ago

add an option to switch off the callback for ui elements, proposal add isContinuously (default to True to keep the current behaviour.

Variable([
    dict(name="foo", ui="Slider", isContinuously=False),
    dict(name="Update", ui="Button")
], globals())
gferreira commented 4 years ago

isContinuous (adjective not adverb :)

justvanrossum commented 4 years ago

In vanilla this is always called continuous. But what does this do different from specifying continuous in args?

typemytype commented 4 years ago

a vanilla.Slider has continuous which means the callback is not called while sliding, only on mouse up...

isContinuous in a Variable dict item is a bit different as it the callback would be ignored completely for that ui control.

justvanrossum commented 4 years ago

Can you explain when that behavior use useful?

typemytype commented 4 years ago

when a script is heavy it makes no sense to have it updating for every tiny slider drag

see https://forum.drawbot.com/topic/257/ui-with-update-function

justvanrossum commented 4 years ago

True. But I think that should be a function of the entire thing, not each individual UI item.

typemytype commented 4 years ago

with this you can choose that your colorWel will update, but not the slider...

and I didnt wanted to add more arguments in the Variables method

justvanrossum commented 4 years ago

But if it doesn't make sense for a slider to update live, it doesn't make sense for the color well to update live.

Variable only takes two argument, what's against adding an argument there?

I would a third one isContinuous, that when False, adds an "Update" button at the bottom of the window, and changes the overall behavior to "not continuous".

justvanrossum commented 4 years ago

Imagine you have a bunch of stuff set up with Variable (btw. shouldn't it be called Variables? I always wondered that). At some point the script becomes too slow for it to behave continuously. It would be silly if the user would need to change all Slider items to be not continuous.

typemytype commented 4 years ago

True

justvanrossum commented 4 years ago

I'm also not convinced that needing an explicit update button is the way to go. What's wrong with doing an implicit update on mouse-up? Like as if Slider has continuous set to True.

justvanrossum commented 4 years ago

I would love the possibility for Variable to simply pass continuous=True to all UI elements that support it, with one flag.

typemytype commented 4 years ago

changed by adding a button, a button makes sense so multiple sliders can be changed and single click.

the vanilla argument can always be passed in the args of an ui item

dict(name="foo" ui="Slider", args=dict(continuous=False))

(mabye this dicussion should happen in the PR)