ynput / ayon-core

Apache License 2.0
32 stars 36 forks source link

Enhancement: Access or embed AYON's Python Script Editor in hosts #743

Open BigRoy opened 1 year ago

BigRoy commented 1 year ago

Is there an existing issue for this?

Please describe the feature you have in mind and explain what the current shortcomings are?

I'd like to embed the Python Console Interpreter module's script editor widget into a few hosts that internally have a very shitty scripting console, like Resolve, Fusion, Substance Painter and Cinema4D (something I've been working on in my spare time).

Each one would need its own settings registry so opening one host doesn't show the scripts stored in the other hosts. I discussed with @iLLiCiTiT something like:

registry = PythonInterpreterRegistry(suffix="fusion")
widget = PythonInterpreterWidget(registry=registry)
widget.show()

But he mentioned it's preferred to then create a dedicated controller class for the tool:

Rather having some base/default controller which has implemented default behavior. And if you want to change it then inherit from it and change some of the behavior.

Class BaseController(object):
    def init_registry(self):
        ...

class HostController(BaseController):
    def init_registry(self):
        ...

(as an example) the controller should require to have implemented methods like get_preferences, save_preferences(self, width, height, splitter_size, tabs) and the logic underneath is up to controller so technically you can totally ignore registry and store it where you need (in extreme cases to workfile) or to the database

How would you imagine the implementation of the feature?

Preferably it's like an extra addon that embeds itself into each of the hosts so that its logic is contained and easily enabled/disabled - maybe even an addon for an integration per host (or that might be overkill?)

Are there any labels you wish to add?

Describe alternatives you've considered:

Live without a decent script editor in some hosts. I've in the past already hacked just the widget already into the hosts in my own branches during development for easier testing. Like for example in OpenRV which I believe currently also lives in the ynput/OpenPype#4839 PR here

openrv_openpype_python_script_editor

Additional context:

No response

[cuID:OP-6121]

BigRoy commented 5 months ago

I've also wanted this a few times in AYON launched applications, e.g. Resolve, Substance Painter, etc. so transferred this to AYON core.

Maybe this could be exposed by default in e.g. the "Experimental Tools" section.

iLLiCiTiT commented 5 months ago

There already is a task for this. To sum up expected changes: The UI should be 100% based on controller. Like the UI show not know from where it loads tabs and where are stored (if are stored). Current console module should disappear, instead we have to create hardcoded action in tray. We can prepare simplified variant to host tools to show console, or as you mentioned to experimental tools.