Python libraries: Difference between revisions
m (Bot: Automated text replacement (- XBMC + {{name}} )) |
m (Robot: Substituting template: Name) |
||
Line 5: | Line 5: | ||
print sys.builtin_module_names</nowiki></pre> | print sys.builtin_module_names</nowiki></pre> | ||
For a list of the other standard libraries, find the file "python26.zlib" in your | For a list of the other standard libraries, find the file "python26.zlib" in your XBMC installations /system/python/ folder, and open it with an archive viewer such as WinRAR or 7-zip. | ||
==== Custom libraries ==== | ==== Custom libraries ==== | ||
In addition to the built-ins and standard libraries, | In addition to the built-ins and standard libraries, XBMC Python uses a handful of custom libraries to expose XBMC functionality to Python. | ||
Up to date documentation about these modules can be found at http://mirrors.xbmc.org/docs/python-docs/ | Up to date documentation about these modules can be found at http://mirrors.xbmc.org/docs/python-docs/ | ||
Line 35: | Line 35: | ||
==== Installing additional libraries ==== | ==== Installing additional libraries ==== | ||
Additional libraries can be installed by adding them to the /system/python/Lib folder of your | Additional libraries can be installed by adding them to the /system/python/Lib folder of your XBMC installation. A Python module placed in this folder can be called from any script or plugin within XBMC. | ||
Of course, you can also place the library files you want to import in your script or plugin folder, directly in the root or in a subfolder. A popular method is to add a "resources" subfolder to your script's folder, and add it to the path within your script. | Of course, you can also place the library files you want to import in your script or plugin folder, directly in the root or in a subfolder. A popular method is to add a "resources" subfolder to your script's folder, and add it to the path within your script. | ||
If you are going to use a module that will possibly used by more add-on you can better create a separate add-on of this so more add-ons can make use of it. Be sure to checkout which modules are already available from our | If you are going to use a module that will possibly used by more add-on you can better create a separate add-on of this so more add-ons can make use of it. Be sure to checkout which modules are already available from our XBMC repository by looking at http://mirrors.xbmc.org/addons/ and choose the XBMC version your are developing for. | ||
[[Category:Add-on development]] | [[Category:Add-on development]] |
Revision as of 20:37, 5 June 2014
Libraries
XBMC Python comes with all the standard modules from Python 2.6. If you need to find a list of them, you can use the following command to generate a list of built-ins:
import sys print sys.builtin_module_names
For a list of the other standard libraries, find the file "python26.zlib" in your XBMC installations /system/python/ folder, and open it with an archive viewer such as WinRAR or 7-zip.
Custom libraries
In addition to the built-ins and standard libraries, XBMC Python uses a handful of custom libraries to expose XBMC functionality to Python.
Up to date documentation about these modules can be found at http://mirrors.xbmc.org/docs/python-docs/
Module | Description |
xbmc | Offers classes and functions that provide information about the media currently playing and that allow manipulation of the media player (such as starting a new song). You can also find system information using the functions available in this library. |
xbmcgui | Offers classes and functions that manipulate the Graphical User Interface through windows, dialogs, and various control widgets. |
xbmcplugin | Offers classes and functions that allow a developer to present information through XBMC's standard menu structure. While plugins don't have the same flexibility as scripts, they boast significantly quicker development time and a more consistent user experience. |
xbmcaddon | Offers classes and functions that manipulate the add-on settings, information and localization. |
xbmcvfs | Offers classes and functions offers acces to the Virtual File Server (VFS) which you can use to manipulate files and folders. |
Installing additional libraries
Additional libraries can be installed by adding them to the /system/python/Lib folder of your XBMC installation. A Python module placed in this folder can be called from any script or plugin within XBMC.
Of course, you can also place the library files you want to import in your script or plugin folder, directly in the root or in a subfolder. A popular method is to add a "resources" subfolder to your script's folder, and add it to the path within your script.
If you are going to use a module that will possibly used by more add-on you can better create a separate add-on of this so more add-ons can make use of it. Be sure to checkout which modules are already available from our XBMC repository by looking at http://mirrors.xbmc.org/addons/ and choose the XBMC version your are developing for.