PyCoreApplication¶
Inherited by: PyGuiApplication
Synopsis¶
This object represents a background instance of Natron. See detailed description…
Functions¶
- def
appendToNatronPath
(path) - def
getSettings
() - def
getBuildNumber
() - def
getInstance
(idx) - def
getActiveInstance
() - def
getNatronDevelopmentStatus
() - def
getNatronPath
() - def
getNatronVersionEncoded
() - def
getNatronVersionMajor
() - def
getNatronVersionMinor
() - def
getNatronVersionRevision
() - def
getNatronVersionString
() - def
getNumCpus
() - def
getNumInstances
() - def
getPluginIDs
() - def
getPluginIDs
(filter) - def
isBackground
() - def
is64Bit
() - def
isLinux
() - def
isMacOSX
() - def
isUnix
() - def
isWindows
() - def
setOnProjectCreatedCallback
(pythonFunctionName) - def
setOnProjectLoadedCallback
(pythonFunctionName)
Detailed Description¶
When running Natron there’s a unique instance of the PyCoreApplication object. It holds general information about the process.
Generally, throughout your scripts, you can access this object with the variable natron that Natron pre-declared for you, e.g.:
natron.getPluginIDs()
Warning
The variable natron belongs to the module NatronEngine, hence make sure to make the following import:
from NatronEngine import*
Otherwise with a regular import you can still access natron by prepending the module:
NatronEngine.natron
Warning
The variable stored in the module NatronEngine contains a reference to a PyCoreApplication. If you need to have the GUI functionalities provided by PyGuiApplication, you must then use the variable natron belonging to the module NatronGui. Hence make sure to make the following import to have access to natron:
from NatronGui import*
With a regular import you can access it using NatronGui.natron.
Warning
Make sure to not make the 2 following imports, otherwise the natron variable will not point to something expected:
#This you should not do!
from NatronEngine import *
from NatronGui import *
#This is OK
import NatronEngine
import NatronGui
#This can also be done for convenience
from NatronEngine import NatronEngine.natron as NE
from NatronGui import NatronGui.natron as NG
This class is used only for background (command-line) runs of Natron, that is when you launch Natron in the following ways:
Natron -b ...
Natron -t
NatronRenderer
For interactive runs of Natron (with the user interface displayed), the derived class PyGuiApplication is used instead, which gives access to more GUI specific functionalities.
You should never need to make a new instance of this object yourself. Note that even if you did, internally the same object will be used and they will all refer to the same Natron application.
In GUI mode, a :doc`PyGuiApplication` can have several projects opened. For each project you can refer to them with pre-declared variables app1 , app2, etc…
In background mode, there would be only 1 project opened, so Natron does the following assignment for you before calling any scripts:
app = app1
See App to access different opened projects.
Member functions description¶
-
class
NatronEngine.
PyCoreApplication
¶
Defines a new variable pointing to the same underlying application that the natron variable points to. This is equivalent to calling:
myVar = natron
-
NatronEngine.PyCoreApplication.
appendToNatronPath
(path)¶ Parameters: path – str
Adds a new path to the Natron search paths. See this section for a detailed explanation of Natron search paths.
-
NatronEngine.PyCoreApplication.
getSettings
()¶ Return type: AppSettings
Returns an object containing all Natron settings. The settings are what can be found in the preferences of Natron.
-
NatronEngine.PyCoreApplication.
getBuildNumber
()¶ Return type: int
Returns the build-number of the current version of Natron. Generally this is used for release candidates, e.g.:
Natron v1.0.0-RC1 : build number = 1 Natron v1.0.0-RC2 : build number = 2 Natron v1.0.0-RC3 : build number = 3
-
NatronEngine.PyCoreApplication.
getInstance
(idx)¶ Parameters: idx – int
Return type: App
Returns the App instance at the given idx. Note that idx is 0-based, e.g.: 0 would return what’s pointed to by app1.
-
NatronEngine.PyCoreApplication.
getActiveInstance
()¶ Return type: App
Returns the App instance corresponding to the last project the user interacted with.
-
NatronEngine.PyCoreApplication.
getNatronDevelopmentStatus
()¶ Return type: str
Returns a string describing the development status of Natron. This can be one of the following values:
- Alpha : Meaning the software has unimplemented functionalities and probably many bugs left
- Beta : Meaning the software has all features that were planned are implemented but there may be bugs
- RC : Meaning the software seems in a good shape and should be ready for release unless some last minute show-stoppers are found
- Release : Meaning the software is ready for production
-
NatronEngine.PyCoreApplication.
getNatronPath
()¶ Return type: sequence
Returns a sequence of string with all natron search paths.
-
NatronEngine.PyCoreApplication.
getNatronVersionEncoded
()¶ Return type: int
Returns an int with the version of Natron encoded so that you can compare versions of Natron like this:
if natron.getNatronVersionEncoded() >= 20101:
...
In that example, Natron’s version would be 2.1.1
-
NatronEngine.PyCoreApplication.
getNatronVersionMajor
()¶ Return type: int
Returns the major version of Natron. If the version is 1.0.0, that would return 1.
-
NatronEngine.PyCoreApplication.
getNatronVersionMinor
()¶ Return type: int
Get the minor version of Natron. If the version is 1.2.0, that would return 2.
-
NatronEngine.PyCoreApplication.
getNatronVersionRevision
()¶ Return type: int
Returns the revision number of the version. If the version is 1.2.3, that would return 3.
-
NatronEngine.PyCoreApplication.
getNatronVersionString
()¶ Return type: str
Returns the version of Natron as a string, e.g.: “1.1.0”
-
NatronEngine.PyCoreApplication.
getNumCpus
()¶ Return type: int
Returns the maximum hardware concurrency of the computer. If the computer has 8 hyper-threaded cores, that would return 16.
-
NatronEngine.PyCoreApplication.
getNumInstances
()¶ Return type: int
Returns the number of :doc`App` instances currently active.
-
NatronEngine.PyCoreApplication.
getPluginIDs
()¶ Return type: sequence
Returns a sequence of strings with all plugin-IDs currently loaded.
-
NatronEngine.PyCoreApplication.
getPluginIDs
(filter) Parameters: filter – str
Return type: sequence
Same as getPluginIDs()
but returns
only plug-ins containing the given filter. Comparison is done without case-sensitivity.
-
NatronEngine.PyCoreApplication.
isBackground
()¶ Return type: bool
Returns True if Natron is executed in background mode, i.e: from the command-line, without any graphical user interface displayed.
-
NatronEngine.PyCoreApplication.
is64Bit
()¶ Return type: bool
Returns True if Natron is executed on a 64 bit computer.
-
NatronEngine.PyCoreApplication.
isLinux
()¶ Return type: bool
Returns True if Natron is executed on a Linux or FreeBSD distribution.
-
NatronEngine.PyCoreApplication.
isMacOSX
()¶ Return type: bool
Returns True if Natron is executed on MacOSX.
-
NatronEngine.PyCoreApplication.
isUnix
()¶ Return type: bool
Returns True if Natron is executed on Unix. Basically this is equivalent to:
if natron.isLinux() or natron.isMacOSX():
-
NatronEngine.PyCoreApplication.
isWindows
()¶ Return type: bool
Returns True if Natron is executed on Windows.
-
NatronEngine.PyCoreApplication.
setOnProjectCreatedCallback
(pythonFunctionName)¶ Param: str
Convenience function to set the After Project Created callback. Note that this will override any callback set in the Preferences–>Python–>After Project created. This is exactly the same as calling:
NatronEngine.settings.afterProjectCreated.set(pythonFunctionName)
Note
Clever use of this function can be made in the init.py script to do generic stuff for all projects (whether they are new projects or loaded projects). For instance one might want to add a list of Formats to the project. See the example here
-
NatronEngine.PyCoreApplication.
setOnProjectLoadedCallback
(pythonFunctionName)¶ Param: str
Convenience function to set the Default After Project Loaded callback. Note that this will override any callback set in the Preferences–>Python–>Default After Project Loaded. This is exactly the same as calling:
NatronEngine.settings.defOnProjectLoaded.set(pythonFunctionName)