diff options
author | Eike Ziller <eike.ziller@qt.io> | 2018-09-27 15:00:08 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2018-09-28 07:31:36 +0000 |
commit | 3412dc563119221bd730c1487937519df0761792 (patch) | |
tree | d738ea0a24c1013e589e69240d6fc91ae13ed999 /docs/extensions.md | |
parent | 3c4cafdf834c9b683501efca72dbbe1093cf6f9a (diff) |
Clean up import hierarchy
PythonExtension.QtCreator.*
-> QtCreator.*
PythonExtension.PluginInstance
-> QtCreator.PythonExtensions
Also enables imports of the form "from QtCreator import Core" it is no
longer necessary to write QtCreator.Core....
Change-Id: Ib9b433868dcc3fc7d1d534c6023bae7bf6d05fec
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'docs/extensions.md')
-rw-r--r-- | docs/extensions.md | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/docs/extensions.md b/docs/extensions.md index 709acff..57a6f15 100644 --- a/docs/extensions.md +++ b/docs/extensions.md @@ -6,27 +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 # Each extension has properties 'name' and 'loaded' -inst.extensionList() +PythonExtensions.extensionList() # Returns the path of the custom location to # where missing dependencies should be pip installed -inst.pythonPackagePath() +PythonExtensions.pythonPackagePath() ``` @@ -42,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.") @@ -50,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) ``` |