Documentation | Tutorials | Hello Python
This tutorial demonstrates how to create a simple application using VS.NET, PyCharm, or another Python IDE.
TatukGIS Developer Kernel for Python (PDK) can be installed with a commonly used package installer for Python – pip
. The only prerequisite for installing PDK is Python, which is bundled with pip
.
If you are not familiar with Python and pip, start here:
You can start writing Python programs using IDLE
– an integrated development environment bundled with Python, but there are a lot of free and commercial dedicated solutions on the market, e.g.:
When your Python environment is ready, install the DK for Python from TatukGIS private repository with:
pip install tatukgis --index-url https://pypi.tatukgis.com/packages/stable/simple
and enter the TatukGIS site credentials.
If you install the PDK on Linux, you have to pass the authentication credentials by providing the username
and password
in the URL:
pip install tatukgis --index-url https://username:password@pypi.tatukgis.com/packages/stable/simple
Use the --force-reinstall
option to install the latest version.
pip install tatukgis --force-reinstall --index-url https://pypi.tatukgis.com/packages/stable/simple
Activate the license before using the PDK. Run Python in the terminal and enter the below 2 lines independently:
import tatukgis.pdk as pdk pdk.TGIS_Utils.ActivateLicense()
Click the Activate now!
button and enter the product code in the following dialog box. The serial number is delivered via email after downloading TatukGIS Developer Kernel for Python products from www.tatukgis.com.
Click the URL in the following dialog box and copy/paste the generated activation code from the TatukGIS activation site.
TatukGIS DK for Python is activated! Now, it’s time to open an IDE and create a new python file (with extension *.py) and paste the below code.
import tatukgis.pdk as pdk import tatukgis.fmx as fmx # A class to create a Python applications with GUI based on FireMonkey Framework (FMX). # Delphi installation is not required. class HelloPythonForm(fmx.TForm): def __init__(self, _owner): # Create a form self.Caption = "Hello DK for Python" self.Width = 600 self.Height = 400 self.Position = fmx.TFormPosition().ScreenCenter # alt: "ScreenCenter" self.OnShow = self.on_show # Add a GIS viewer to the form self.GIS = pdk.TGIS_ViewerWnd(self) self.GIS.Parent = self self.GIS.Align = "Client" self.GIS.Mode = pdk.TGIS_ViewerMode().Zoom def on_show(self, _sender): # Download if necessary and returns path to the sample data directory. sample_data_dir = pdk.TGIS_Utils.GisSamplesDataDirDownload() # Open a Shapefile and add to the map self.GIS.Open(sample_data_dir + "World/WorldDCW/world.shp") def main(): # Minimal code to run an FMX-based application in Python fmx.Application.Initialize() fmx.Application.Title = 'Hello DK for Python' fmx.Application.MainForm = HelloPythonForm(fmx.Application) fmx.Application.MainForm.Show() fmx.Application.Run() fmx.Application.MainForm.Destroy() if __name__ == '__main__': main()
Run the Python script to display the TatukGIS map viewer with the world shapefile loaded.
To go further, find our samples for Python.