A tool made for running and testing Python script files in QGIS.
Kolba is a lightweight alternative to a traditional QGIS plugin repository.
Instead of packaging and updating plugins manually, it allows users to run Python scripts directly from a local/shared folder inside QGIS. This makes bug fixes and updates much faster: once script is changed, all users automatically work with the latest version without reinstalling or updating anything.
Project background
This tool is an alternative to maintaining a local QGIS plugin repository. Previously, I developed plugins for my colleagues and distributed them through a shared repository on our office network. The plugins were used actively, which naturally led to frequent bug reports. The support workflow became burdensome: collecting feedback, fixing issues, repackaging the plugin into a ZIP file, updating the repository, and notifying everyone about the new version. The update notifications, in particular, were inconvenient for users.To simplify this process, I created Kolba — a wrapper widget for running Python scripts directly in QGIS. It acts like a file browser that displays only Python scripts and allows users to execute them by doubleclick. All scripts are stored in a shared network folder, so if someone reports an issue, I simply fix the script in that folder. Users do not need to update anything — they just run specific script again and immediately get the latest version.
This approach has been well-received by colleagues due to its simplicity and minimal maintenance effort.
The interface of Kolba is simple for understanding: on the top there is a control panel and path to folder with script files. Path line contains buttons on the right side:
- dropdown list of saved paths
- shows favorite scripts
- updates script list by scanning current path
- loader of scripts from the internet
- folder selector
Bookmarks - appeared in v1.5 and provide a quick switch between paths saved in Kolba settings.
Below path line there are two sections: the left is script list, the right is a window with description when script is selected. In addition to two standard icons (pin/unpin, close widget) there are another two buttons:
User should specify a direct path to directory with Python files in a Kolba's header text line box and hit Enter. Then on the left side of Kolba there will be shown a list of Python files. Users can run them while developers are able to edit them in some external code editor. When user double-click a script in Kolba, the most up-to-date version of selected script will be launched.
Scripts which are run from Kolba should have all needed libraries imported in order to work. Otherwise Kolba will tell that something is wrong with selected script and an error will be printed in Python console of QGIS. So, despite the fact that some libraries are imported in QGIS from startup, they should be re-imported in local script file.
For example there is a script which can be run from Python console:
from qgis._core import *
from qgis.utils import iface
from qgis.PyQt.QtCore import Qt
from qgis.PyQt.QtWidgets import QMainWindow, QTableWidget, QTableWidgetItem, QPushButton, QVBoxLayout, QWidget, QHeaderView
class TestWidget(QMainWindow):
"""Get vector layers with feature count from current project
"""
def __init__(self):
super().__init__(parent=iface.mainWindow())
self.setWindowTitle("Vector layers stats")
self.resize(400, 300)
self.setWindowFlags(self.windowFlags() | Qt.WindowType.WindowStaysOnTopHint)
self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
# container
container = QWidget()
self.setCentralWidget(container)
layout = QVBoxLayout(container)
# table
self.table = QTableWidget()
self.table.setColumnCount(2)
self.table.horizontalHeader().setSectionResizeMode(0, QHeaderView.ResizeMode.Interactive)
self.table.horizontalHeader().setSectionResizeMode(1, QHeaderView.ResizeMode.Stretch)
self.table.setHorizontalHeaderLabels(["Layer name", "Feature count"])
layout.addWidget(self.table)
# update button
button = QPushButton("Update")
button.clicked.connect(self.fill_table)
layout.addWidget(button)
self.show()
def fill_table(self):
layers = [l for l
in QgsProject.instance().layerTreeRoot().layerOrder()
if isinstance(l, QgsVectorLayer)
]
self.table.setRowCount(len(layers))
for i, layer in enumerate(layers):
# fill layer and feature numbers
self.table.setItem(i, 0, QTableWidgetItem(layer.name()))
self.table.setItem(i, 1, QTableWidgetItem(str(layer.featureCount())))
app = TestWidget()Note
Here iface and PyQt elements are imported in order to make script run from Kolba.
Copy and paste the code above to a blank Python script file and name it like my_widget.py. In order to update contents of script list in Kolba widget, a blue refresh button should be pressed. Finally, a doubleclick on script will execute it. Same thing can be achieved in by selecting script in a list and pressing a ▶︎ button.
Kolba is actually runs a Python script file the same way like in QGIS Python console editor. But it also passes additional variables with running code. They are:
- wrapper - Kolba instance
- project_folder - current folder in Kolba
- script_name - script filename
This variables can be used in some cases.
For example, in a way to prevent widgets from opening them as multiple instances. Kolba is adding a new attribute for an iface object: iface.kolba_plugin. It is basically a dictionary which is used for keeping instances of running widgets.
So if you need to run only single instance of specific widget, add strings:
(script_name:=globals().get("script_name")) and hasattr(iface,"kolba_plugin") and iface.kolba_plugin.__setitem__(script_name, self) # - where widget is shown
...
(script_name:=globals().get("script_name")) and hasattr(iface,"kolba_plugin") and iface.kolba_plugin.__setitem__(script_name, None) # - where widget is closing, i.e. closeEvent functionThese strings make it safe to run scripts within Kolba or outside of it.
Completed example:
from qgis._core import *
from qgis.utils import iface
from qgis.PyQt.QtCore import Qt
from qgis.PyQt.QtWidgets import QMainWindow, QTableWidget, QTableWidgetItem, QPushButton, QVBoxLayout, QWidget, QHeaderView
class TestWidget(QMainWindow):
"""Get vector layers with feature count from current project
"""
def __init__(self):
super().__init__(parent=iface.mainWindow())
self.setWindowTitle("Vector layers stats")
self.resize(400, 300)
self.setWindowFlags(self.windowFlags() | Qt.WindowType.WindowStaysOnTopHint)
self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
# container
container = QWidget()
self.setCentralWidget(container)
layout = QVBoxLayout(container)
# table
self.table = QTableWidget()
self.table.setColumnCount(2)
self.table.horizontalHeader().setSectionResizeMode(0, QHeaderView.ResizeMode.Interactive)
self.table.horizontalHeader().setSectionResizeMode(1, QHeaderView.ResizeMode.Stretch)
self.table.setHorizontalHeaderLabels(["Layer name", "Feature count"])
layout.addWidget(self.table)
# update button
button = QPushButton("Update")
button.clicked.connect(self.fill_table)
layout.addWidget(button)
self.show()
(script_name:=globals().get("script_name")) and hasattr(iface,"kolba_plugin") and iface.kolba_plugin.__setitem__(script_name, self) # widget is stored in Kolba dict, so it won't open more than one time
def fill_table(self):
layers = [l for l
in QgsProject.instance().layerTreeRoot().layerOrder()
if isinstance(l, QgsVectorLayer)
]
self.table.setRowCount(len(layers))
for i, layer in enumerate(layers):
# fill layer and feature numbers
self.table.setItem(i, 0, QTableWidgetItem(layer.name()))
self.table.setItem(i, 1, QTableWidgetItem(str(layer.featureCount())))
def closeEvent(self, event):
(script_name:=globals().get("script_name")) and hasattr(iface,"kolba_plugin") and iface.kolba_plugin.__setitem__(script_name, None) # widget is reset in Kolba dict, so it is ready for re-run
app = TestWidget()Video guide provided below:
kolba_guide.mp4
Since v1.2 scripts can be downloaded from web URLs. Find a 
WebScripts widget provide loading scripts from direct URL and get custom sets of scripts from a URL specified in Settings.
To load a specific script enter the direct URL to Python script file in Custom script line.
For example, https://gisworks.ru/qgis_tools/my_widget.py
After that, press search button. After a moment widget will tell if script is found or not.
If URL is valid script can be saved with a button Save. After that script will be appeared in a list of Kolba.
Script set is a list of script URLs which is taken from another URL. Instead of searching each script manually user can select specific script and download it.
Note
Since v1.6 there are two domains for script set: gisworks.ru and gisworks.org. Both sites provide the same set of scripts. But the first one is made for users from Russia who have problems with access to European/American hostings, while the second is for those who cannot access Russian hosting. Domain can be manually changed in Kolba settings
The right part of Kolba window is used to show a description of selected script. Since v1.2 all description data stores in script file at the beginning. Description contain rows like:
- description - description itself, since version 1.4 supports HTML syntax
- version - number of version (needed for updates check)
- reference - URL containing information or guide to plugin
- author - developer name
- author_mail - e-mail of author
- original_url - URL where script stores
Check an example:
"""
description: My test tool
version: 1.0
reference: https://github.com/pavelpereverzev/kolba
author: Me
author_mail: me@mail.com
original_url: https://gisworks.ru/qgis_tools/my_widget.py
"""
from qgis._core import *
from qgis.utils import iface
from qgis.PyQt.QtCore import Qt
from qgis.PyQt.QtWidgets import QMainWindow, QTableWidget, QTableWidgetItem, QPushButton, QVBoxLayout, QWidget, QHeaderView
class TestWidget(QMainWindow):
"""Get vector layers with feature count from current project
"""
def __init__(self):
super().__init__(parent=iface.mainWindow())
self.setWindowTitle("Vector layers stats")
self.resize(400, 300)
self.setWindowFlags(self.windowFlags() | Qt.WindowType.WindowStaysOnTopHint)
self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
# container
container = QWidget()
self.setCentralWidget(container)
layout = QVBoxLayout(container)
# table
self.table = QTableWidget()
self.table.setColumnCount(2)
self.table.horizontalHeader().setSectionResizeMode(0, QHeaderView.ResizeMode.Interactive)
self.table.horizontalHeader().setSectionResizeMode(1, QHeaderView.ResizeMode.Stretch)
self.table.setHorizontalHeaderLabels(["Layer name", "Feature count"])
layout.addWidget(self.table)
# update button
button = QPushButton("Update")
button.clicked.connect(self.fill_table)
layout.addWidget(button)
self.show()
(script_name:=globals().get("script_name")) and hasattr(iface,"kolba_plugin") and iface.kolba_plugin.__setitem__(script_name, self) # widget is stored in Kolba dict, so it won't open more than one time
def fill_table(self):
layers = [l for l
in QgsProject.instance().layerTreeRoot().layerOrder()
if isinstance(l, QgsVectorLayer)
]
self.table.setRowCount(len(layers))
for i, layer in enumerate(layers):
# fill layer and feature numbers
self.table.setItem(i, 0, QTableWidgetItem(layer.name()))
self.table.setItem(i, 1, QTableWidgetItem(str(layer.featureCount())))
def closeEvent(self, event):
(script_name:=globals().get("script_name")) and hasattr(iface,"kolba_plugin") and iface.kolba_plugin.__setitem__(script_name, None) # widget is reset in Kolba dict, so it is ready for re-run
app = TestWidget()You can also upload script to some hosting and let other users to download it directly from Kolba. Script file will not run right after download is completed so you will have a time to check what script actually does.
Note
None of these lines are required, but description makes it better for colleagues to understand a tool someone made.
version and original_url should be both set carefully if developer decides to make updates on his tool. For example after changing number at version from 1.0 to 1.1 in script located in https://gisworks.ru/qgis_tools/my_widget.py user will see and Update tool button at the bottom of Kolba description window.
Kolba settings contains customizable settings of plugin:
- paths manager: add, delete, edit folder paths, change their order
- favorites checkbox: adds a new button which allows to get user's favorite tools
- developers options: adds some features to script list
- bookmarks manager: set path as buttons in main widget for quick switch
- WebScript root folder and path to script set
- import/export kolba paths settings
- interface settings: splitter orientation and theme
Paths manager allows to add, delete or edit paths in plugin. For example you keep stable versions of tools in specific folder while some work-in-process tools have to be kept in another folder. By adding another folder user can switch between folders in main widget's dropdown list. Re-ordering paths is also here: drag and drop path lines to change an order of them.
Favorites enabled turns on and off an additional Favorites button which can show user tools marked as favorites. To make tool as favorite user should right-click a script and select Add to favorites option. After that if user clicks Favorites button a list of them appear. To remove tool from favorites section user should open favorites list and also right-click any script: there will be a context menu with a single option: Remove from favorites.
Developers options allows user to drag'n'drop script to QGIS Python console editor or to any external text/code editor (like Visual Studio Code, PyCharm, Sublime). May be useful for developers who don't want to spend time in finding script in file explorer. Also this option adds two options to scripts: Open in Python console and Reveal in file explorer. The first one is for loading script in QGIS Python console editor and the second is for opening folder containing script file with highlight of it.
Bookmarks manager provides keeping certain path as buttons in main widget. In order not to open dropdown list from main widget's line, user can set folders as bookmark buttons and they appear in main widget between path line and content blocks. User can add a new path bookmark or use existing paths from settings list to make bookmarks from them.
WebScript default location is a URL to the root folder of scripts which can be downloaded from the internet. Default URL is https://gisworks.ru/qgis_tools which means that if user type my_widget in WebScript search tool, it will go to https://gisworks.ru/qgis_tools/my_widget.py path.
WebScript custom set URL is a link to json file which is a list of tools that can be presented in Script set section. Default URL is https://gisworks.ru/kolba_set.json and the json structure should look like:
[
{"id": "script_name", "url": "https://some_site.com/script_name.py"},
{"id": "another_script_name", "url": "https://some_another_site.com/another_script_name.py"}
]
Import/Export config are buttons made for saving current paths, bookmarks and WebScript setting into *.json config file, so user can save it and load on another computer. May be useful in team work for Kolba setting up.
Tools widget orientation allows to modify a layout of script list and description widgets.
Theme is an option to personalize user's Kolba. User can put an jpg/png image or gif animation as a background picture of the whole Kolba interface. Transparency is also can be set.
see updates
- bookmarks
- custom scripts set url setting for WebScripts
- import/export config
- webscript search case sensitivity
- code cleaning
- fixing bugs which were incompatible with modern QGIS plugin checks
- Qt6 support
- fixed crash on non-valid url of WebScript
- added WebScript default url setting
- WebScript description widget HTML support
- fixed default writable path detection
- support fixes for Linux and MacOS
- interface updates (tools splitter widget orientation, removing unused buttons, actions fixing)
- partial code cleaning
- fixing WebScript class signal crash caused by removing its instance
- first public version of plugin
- making plugin as a separate tool from easyPlugin










