python function not working ?

Adding :

app.getProjectParam(‘frameRange’).setValue(1, 25)

to init.py file doesn’t produce any result, nor any error message.
Note that every other parameter can be accessed and tweaked using the ‘getProjectParam’ function.

Hello,
You can use app.frameRange.set(1, 25) for that…

Btw, do you know how to set the current frame on the timeline ?
I’ve looked for that but haven’t found anything.

Ah yes, thanks,
since the ‘frameRange’ parameter uses Int2DParam parameters, the set(x,y) function is required, not the setValue() one.

To get to a specific frame, i think it’s this function :

NatronGui.PyTabWidget.seek( frame )

doc : https://natron.readthedocs.io/en/rb-2.3/devel/PythonReference/NatronGui/PyViewer.html#pyviewer

ex :

myViewer = app.getViewer(‘Viewer1’)
myViewer.seek(10)

Thanks a lot, I’ve searched a lot through the API but at the wrong place !
It’s working like a charm !

Small script doing the job.
Since once a ‘Viewer’ is set to go to a specific frame, all other viewers are synchronized, i set a break instruction after the first one in the list (in case you have more than 1 viewer in the Node Graph).

get viewer.zip (333 Bytes)

Please collect all these questions about the python API, and start a “howto” or “faq” question in the Natron python doc.

I’ll do.
Could you tell me where is described the process to contribute to the doc ?

https://natron.readthedocs.io/en/rb-2.3/devel/gettingstarted.html

This should be the base section where we should give the snippets. Although many snippets are there but mostly created to work with script editor directly.
Without expertise in python, these are hard to translate in a .py file to create extra functions like callback and set params for example.

My proposal would be to write a simple demo to work with py scripts.
Like creating a simple gizmo and giving extra features with callbacks in my_plugExt. Also may be including external python library.

IMHO Godot has revolutionized the doc style for a software. Usually software docs are the worst document (enjoy wise) as a learning resource but Any Godot user can grasp all essential of this engine just by covering this section:
https://docs.godotengine.org/en/3.1/getting_started/step_by_step/index.html

@devernay @fabiof17
Folks is it right that Natron Python structure is like this?

GUI
	-> Effect
		-> Param
			-> Callback

If so, then I think the doc structure can be like this or at least mention as a diagram in introduction.
Please feel free to correct inherited and same classes like “AppSetting” can go in Effect stage as well.
It will clarify many problems. I can make a narrative for review as well.
Thanks.