drawbot icon indicating copy to clipboard operation
drawbot copied to clipboard

with context for newDrawing() / endDrawing()

Open roberto-arista opened this issue 3 years ago • 7 comments

👋

I find myself more and more running drawBot outside of the app, and I often encapsulate my code between newDrawing() and endDrawing(). Would you be open to add a with context as with savedState() to the API?

If yes, I could take care of opening a pull request using savedState as a reference : )

roberto-arista avatar Apr 04 '22 10:04 roberto-arista

Yes.

What name do you propose?

with newDrawing():
    ....

Or a new name?

justvanrossum avatar Apr 04 '22 10:04 justvanrossum

I assume

with newDrawing():
    ...

could cause overshadowing issues, right?

What about a simple

with drawing():
    ...

?

Maybe too simple?

roberto-arista avatar Apr 04 '22 11:04 roberto-arista

Or maybe even "Drawing" (cap-D)?

justvanrossum avatar Apr 04 '22 11:04 justvanrossum

Yep!

roberto-arista avatar Apr 04 '22 11:04 roberto-arista

+1

why capitalise? it will not be a class name

typemytype avatar Apr 04 '22 11:04 typemytype

Not sure this should be an argument, but in drawbot-skia, the place to implement this, is a class named "Drawing" :) https://github.com/justvanrossum/drawbot-skia/blob/master/src/drawbot_skia/drawing.py

justvanrossum avatar Apr 04 '22 12:04 justvanrossum

But in terms of API is should probably just be a contextlib.contextmanager function, indeed not unlike savedState(). Perhaps "drawing" is fine, too.

justvanrossum avatar Apr 04 '22 12:04 justvanrossum