![]() To run a script, you must add it to Script Runner using the Add Script tool on the toolbar. If not, Script Runner won't load your script. The important thing is to be sure you have defined a run_script function. It then calls a method in the Loader class named load_shapefiles to do something useful-in this case, load all the shapefiles in a specified directory.Īlternatively, you could choose not to use classes and just do everything within the run_script function, including having it call functions in the same script or others you might import. In this example, the run_script creates an instance (ldr) of a class named Loader that is defined in the same source file. Here is an example of a simple run_script function:ĭef run_script ( iface ): ldr = Loader ( iface ) ldr. You don't have to use the iface object in your script but your run_script function must accept it as an argument. A reference to the object will be passed to your run_script function. This is the standard entry point used by Script Runner. In order for Script Runner to execute your script you must define a run_script function that accepts a single argument. Here is some additional information from the Help tab of the plugin: Requirements In order for your script to work with ScriptRunner it has to implement a single function as an entry point. In addition, you can view information about the classes, methods, and functions in your module as well as browse the source: PYTHON RUNNER FULLYou can then run them to automate QGIS tasks and have full access to the PyQGIS API. The Script Runner plugin allows you to add your scripts to a list so they are readily available. Following up on my last post, Running Scripts in the Python Console, I created a plugin to simplify running scripts: ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |