aboutsummaryrefslogtreecommitdiffstats
path: root/docs/extensions.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/extensions.md')
-rw-r--r--docs/extensions.md37
1 files changed, 16 insertions, 21 deletions
diff --git a/docs/extensions.md b/docs/extensions.md
index 7152ef6..57a6f15 100644
--- a/docs/extensions.md
+++ b/docs/extensions.md
@@ -6,33 +6,28 @@ for Qt Creator.
## Importing Qt Creator specific modules
Currently, the bindings are available from Python under the following names:
```Python
-from PythonExtension import QtCreator # Imports the generated module for the typesystem
-from PythonExtension import PluginInstance # Imports the plugin instance
+from QtCreator import Utils # Imports Qt Creator's Utils helper library
+from QtCreator import Core # Imports Qt Creator's Core plugin API
+from QtCreator import PythonExtensions # Imports Python extension specific helper functions
```
-## `PythonExtension.PluginInstance`
+## `QtCreator.PythonExtensions`
This is the Python binding for the extension manager that works on the C++ side. It provides the
-following functions, that can (and should) be used from Python:
+following functions, that can be used from Python:
```Python
-from PythonExtension import PluginInstance as inst
+from QtCreator import PythonExtensions
# Returns a PySide QDir which points to the extension directory
-inst.extensionDir()
+PythonExtensions.extensionDir()
# Returns a list with the names of all Python extensions
-# If loaded only is supplied as True, only extensions that
-# where loaded successfully are returned
-inst.extensionList(loadedOnly = False)
-
-# Mark an extension as loaded
-# This should normally not be used and exists mainly
-# for use by the extension manager
-inst.flagAsLoaded("name_of_extension")
+# Each extension has properties 'name' and 'loaded'
+PythonExtensions.extensionList()
# Returns the path of the custom location to
# where missing dependencies should be pip installed
-inst.pythonPackagePath()
+PythonExtensions.pythonPackagePath()
```
@@ -48,7 +43,7 @@ add a new action container, that holds a sub-menu.
The following code snippet illustrates how to add a new menu.
```Python
-from PythonExtension import QtCreator
+from QtCreator import Core
def hello():
print("Hello World.")
@@ -56,24 +51,24 @@ def hello():
# By convention, the menuId starts with "Python"
menuId = "Python.SmallMenu.Menu"
-menu = QtCreator.Core.ActionManager.createMenu(menuId)
+menu = Core.ActionManager.createMenu(menuId)
menu.menu().setTitle("My menu")
menu.menu().addAction("My action", hello)
-# Add our new menu to the "Tools" menu in QtCreator
-QtCreator.Core.ActionManager.actionContainer("QtCreator.Menu.Tools").addMenu(menu)
+# Add our new menu to the "Tools" menu in Qt Creator
+Core.ActionManager.actionContainer("QtCreator.Menu.Tools").addMenu(menu)
```
### Adding a new action directly
The following code snippet illustrates how to add a new action to an existing action container.
```Python
-from PythonExtension import QtCreator
+from QtCreator import Core
def hello():
print("Hello World.")
# Add a new action to the "Tools" menu
-menu = QtCreator.Core.ActionManager.actionContainer("QtCreator.Menu.Tools")
+menu = Core.ActionManager.actionContainer("QtCreator.Menu.Tools")
menu.menu().addAction("My action", hello)
```