Python Scripting

The python scripts can be found here:

%appdata%\10x\PythonScripts\

When 10x starts all scripts in that folder are executed. When a script changed its environment will be reset and it will be executed again.


Hello World Example

import N10X

def HelloWorld():
	print("Hello World!");
						

This creates a ypthon function called HelloWorld that can be called from the 10x command prompt (control+shift+X) or bound to a key. "Hello World" will be printed to the 10x output panel.


This example registers a callback

import N10X

def OnWorkspaceOpened():
	print("Hello Workspace!");

N10X.Editor.AddOnWorkspaceOpenedFunction(OnWorkspaceOpened)
						

Because the AddOnWorkspaceOpenedFunction call is in the global scope it will be executed when the script is executed. This registers a function to be called when a workspace is opened. When a workspace is opened "Hello Workspace" will be output to the 10x output panel.

The 10x Python API

For a full list of all the 10x python commands see the Python API

Adding Packages

To add packages to the 10x python installation copy the package file or folder to the site-packages folder in the 10x install folder and restart 10x.

C:\Program Files\PureDevSoftware\10x\Lib\site-packages\

Python script library

You can find python scripts developed by the 10x community here:

https://github.com/slynch8/10x/tree/main/PythonScripts



See also:

Python API