Wikipedia:Huggle/PRM

Since huggle 3x users are allowed to create a python extensions for huggle. This is a python reference manual for huggle.

Introduction
Python is interpreted language, you can find more about it on its article or on internet. This manual is intended for experienced pythonists.

How to write and load my extension into huggle
Every python extension is a single python module inside a .py file, which must be stored in folder extensions (which is in a directory where huggle is installed). These files are loaded by huggle on start.

huggle module
There is an extra module called "huggle" which is available only when script is loaded within huggle embedded interpretor. This is a module that contains functions which are C api's for the huggle's core. You can use these functions in order to interact with huggle.

There is a file called huggle.py (https://github.com/huggle/huggle3-qt-lx/blob/master/documentation/huggle.py) which exists just as a documentation of these functions. They are all written in C++ and their source code is available in pythonengine.cpp

Hooks
Huggle has lot of internal events that you can hook to, using its extension hooks. These are virtual functions. You can override them in your python script (just by creating them) and they will be called by huggle. Bellow is list of all hooks:

hook_main_window_is_loaded
Called when MainWindow of huggle is loaded. This hook should return true on success or false on errors. Example:

Enable debug logs
Huggle provides verbose logs informing about most of operations that are happening inside huggle core. You can enable them by passing parameter -v to huggle (or more of them, for example -vvvvvvv).

Why my extension doesn't load?
Check:
 * Is huggle compiled with python support? You can open help -> about to figure out
 * Enable debug logs and read why it doesn't load