Editor Python Script Example
In addition to support for other Python IDE's, the TatukGIS Editor's built-in Python scripting environment includes a simple Python IDE called the TatukGIS Python Debugger that is designed to make creating, modifying, and debugging Python code as easy and efficient as possible. The Python Debugger is used in this demonstration.
Portable Visual Library
An important aspect of writing a script is the ability to design elements of a custom GUI, which typically involves dialog boxes, buttons, text entry, etc. Along with Python support and the Python Debugger, the latest Editor version introduces our own, TatukGIS home-brewed, framework for GUI design called Portable Visual Library (PVL). As the name implies, PVL framework is platform-independent, meaning the same code will run on Windows, MacOS, Linux, etc. Use of PVL, therefore, opens doors for future Editor versions. PVL is used in a number of the Editor wizards and dialog boxes.
A second important advantage of PVL is, by design, it is simpler and easier to use than VCL, FMX, WinForms, WPF and other development technologies because PVL is designed specifically for creating user interface dialogues, as opposed to entire applications.
The following demonstration uses the Python Debugger with PVL to write a script to create an empty form, add buttons with logic to the form, and design a groupbox and simple modal form. Before we start coding, a brief description of the Python Debugger is in order.
Python Debugger
The TatukGIS Python Debugger is a powerful tool enabling the user to create, debug, and run Python code. Thanks to the Debugger’s compatibility with the TatukGIS Editor, it can be used to write scripts to implement customizations, such as to automate trivial tasks to improve user productivity, or to enable the Editor with additional features and advanced functionality such as derived from the vast Developer Kernel API.

The Debugger workspace, visible in the above image, is composed of three zones. An upper zone contains all buttons needed to debug and run code, a middle zone provides an area for editing code, and a lower zone contains three panels that present useful information during the program runtime: local variables, stack, and output/console.
To start debugging a script, we need to click on the button with the bug symbol.

This establishes a debugging session and activates debug-time buttons used to control its execution.

These buttons provide typical debugger behavior: run/continue, stop, pause set-over a line, step-into a function, and step-out from the current function.
First form
The code presented below starts by using PVL to create an empty form. This requires creating a class that inherits from the PVL component – PvlForm. The form is initialized with three basic properties: height and width to define its size and a caption that will be displayed at the top of the form. Then the code creates an instance of this class - frm. The function Show is called to present the form on the screen. At the end, a function is added to make the script run upon every frame.
import tatukgis_editor as pdk
class Form(pdk.TGIS_PvlForm):
def __init__(self, _owner) -> None:
self.ClientWidth = 195
self.ClientHeight = 160
self.Caption = 'Example form'
frm = Form(pdk.GIS)
frm.Show()
def process_event():
pass
pdk.RunPvl(frm, process_event)
The resulting form appears in the following image.

First button
After creating a basic form, we can now add some content to it. The following code adds a button to the center of the form. Similar to creating a form instance, it is necessary to specify the owner of the button, which in this case is the form itself. We do this by passing the form context to a component constructor. The button is provided with distances from the top and left edges of the form. The buttonClick property is used to associate the button function to a click event. The function triggered by a click on the button displays the message to the console.
import tatukgis_editor as pdk
class Form(pdk.TGIS_PvlForm):
def __init__(self, _owner) -> None:
self.ClientWidth = 195
self.ClientHeight = 160
self.Caption = 'Example form'
self.button = pdk.TGIS_PvlButton(self.groupBox.Context)
self.button.Top = 100
self.button.Left = 80
self.button.Caption = "EXAMPLE"
self.button.Width = 80
self.button.Height = 25
self.button.OnCLick = self.buttonClick
def buttonClick(self, _sender):
print('Byton clicke!')
frm = Form(pdk.GIS)
frm.Show()
def process_event():
pass
pdk.RunPvl(frm, process_event)
The button added to the center of form is visible in the next image.

Clicking on the button prints the message to the debugger output panel.
.png.aspx?lang=en-US)
Groupbox and simple modal form
Now that we understand how to add content to the form, let’s go further by organizing content (multiple components) into a groupbox on the form for presentation and logical navigation. This requires adding some more content to the form.
The code presented below creates a groupbox for containing any other components we wish to include. The code specifies the size parameters, position, and the caption to be displayed at the top of the box. The code then adds two radio buttons. Because the radio buttons are kept in the same groupbox, they can work interdependently so that only one of the buttons can be selected at any time. The code also provides that one of the radio buttons is selected when the form is initialized. The code also places a button to call the function the modal window will display.
import tatukgis_editor as pdk
import webbrowser
class Form(pdk.TGIS_PvlForm):
def __init__(self, _owner) -> None:
self.ClientWidth = 195
self.ClientHeight = 160
self.Caption = 'Example form'
# ==========================================================
# OPEN CHOSEN MODAL WITH PROVIDED TEXT
self.groupBox = pdk.TGIS_PvlGroupBox(self.Context)
self.groupBox.Top = 5
self.groupBox.Left = 5
self.groupBox.Width = self.ClientWidth - 10
self.groupBox.Height = 120
self.groupBox.Caption = 'Custom modal'
self.errorModalButton = pdk.TGIS_PvlRadioButton(self.groupBox.Context)
self.errorModalButton.Top = 20
self.errorModalButton.Left = 25
self.errorModalButton.Width = self.groupBox.Width - 10
self.errorModalButton.Height = 20
self.errorModalButton.Caption = 'Error modal'
self.infoModalButton = pdk.TGIS_PvlRadioButton(self.groupBox.Context)
self.infoModalButton.Top = 40
self.infoModalButton.Left = 25
self.infoModalButton.Width = self.groupBox.Width - 10
self.infoModalButton.Height = 20
self.infoModalButton.Caption = 'Info modal'
self.infoModalButton.Checked = True
self.modalText = pdk.TGIS_PvlEdit(self.groupBox.Context)
self.modalText.Top = 65
self.modalText.Left = 5
self.modalText.Width = self.groupBox.Width - 10
self.modalText.Height = 20
self.buttonOpenCustomModal = pdk.TGIS_PvlButton(self.groupBox.Context)
self.buttonOpenCustomModal.Top = 90
self.buttonOpenCustomModal.Left = 5
self.buttonOpenCustomModal.Width = self.groupBox.Width - 10
self.buttonOpenCustomModal.Height = 25
self.buttonOpenCustomModal.Caption = 'Open'
self.buttonOpenCustomModal.OnClick = self.buttonOpenCustomModalClick
# ==========================================================
The following code adds two additional buttons at the bottom of the form. One button closes the form and the other button sends the user to help documentation. The code also adds a connection between showing an event on the form and a function that is still to be created.
# ==========================================================
# BOTTOM OPERATION BUTTONS
self.helpButton = pdk.TGIS_PvlButton(self.Context)
self.helpButton.Top = 130
self.helpButton.Left = 5
self.helpButton.Width = 92
self.helpButton.Height = 25
self.helpButton.Caption = 'Help'
self.helpButton.OnClick = self.helpButtonClick
self.cancelButton = pdk.TGIS_PvlButton(self.Context)
self.cancelButton.Top = 130
self.cancelButton.Left = 100
self.cancelButton.Width = 92
self.cancelButton.Height = 25
self.cancelButton.Caption = 'Cancel'
self.cancelButton.OnClick = self.cancelButtonClick
# ==========================================================
self.OnShow = self.formOnShow
Underneath the initialization, we add four previously defined functions. One function is connected to the form event and the others are used by button click events. The form event displays a short message to the console and focuses on text edited on the form.
The next set of code provides the three functions to handle button logic. One function collects data (provided by the radio buttons and text editor) and then opens the modal window with this data. Another function closes the window and ends the script. The third function opens a website providing documentation.
# ==========================================================
# FORM
# ==========================================================
def formOnShow(self, _sender):
print('Printed on show')
self.modalText.SetFocus()
# ==========================================================
# BUTTONS
# ==========================================================
def buttonOpenCustomModalClick(self, _sender):
if self.errorModalButton.Checked:
modalWindow = pdk.TGIS_PvlErrorDialog(self.Context)
elif self.infoModalButton.Checked:
modalWindow = pdk.TGIS_PvlInfoDialog(self.Context)
modalWindow.Text = f'Your text: {self.modalText.Text}'
modalWindow.Title = 'Modal window'
modalWindow.Execute()
def cancelButtonClick(self, _sender):
self.Close()
def helpButtonClick(self, _sender):
webbrowser.open('https://docs.tatukgis.com/EDT5/guide:help:tools:tools')
The final code, shown below, is the same as used earlier to create the form and a button on the form. It creates an instance of the form and a function to display the prepared form.
frm = Form(pdk.GIS)
frm.Show()
def process_event():
pass
pdk.RunPvl(frm, process_event)
The resulting groupbox and modal window are pictured below.


Full code
import tatukgis_editor as pdk
import webbrowser
class Form(pdk.TGIS_PvlForm):
def __init__(self, _owner) -> None:
self.ClientWidth = 195
self.ClientHeight = 160
self.Caption = 'Example form'
# ==========================================================
# OPEN CHOSEN MODAL WITH PROVIDED TEXT
self.groupBox = pdk.TGIS_PvlGroupBox(self.Context)
self.groupBox.Top = 5
self.groupBox.Left = 5
self.groupBox.Width = self.ClientWidth - 10
self.groupBox.Height = 120
self.groupBox.Caption = 'Custom modal'
self.errorModalButton = pdk.TGIS_PvlRadioButton(self.groupBox.Context)
self.errorModalButton.Top = 20
self.errorModalButton.Left = 25
self.errorModalButton.Width = self.groupBox.Width - 10
self.errorModalButton.Height = 20
self.errorModalButton.Caption = 'Error modal'
self.infoModalButton = pdk.TGIS_PvlRadioButton(self.groupBox.Context)
self.infoModalButton.Top = 40
self.infoModalButton.Left = 25
self.infoModalButton.Width = self.groupBox.Width - 10
self.infoModalButton.Height = 20
self.infoModalButton.Caption = 'Info modal'
self.infoModalButton.Checked = True
self.modalText = pdk.TGIS_PvlEdit(self.groupBox.Context)
self.modalText.Top = 65
self.modalText.Left = 5
self.modalText.Width = self.groupBox.Width - 10
self.modalText.Height = 20
self.buttonOpenCustomModal = pdk.TGIS_PvlButton(self.groupBox.Context)
self.buttonOpenCustomModal.Top = 90
self.buttonOpenCustomModal.Left = 5
self.buttonOpenCustomModal.Width = self.groupBox.Width - 10
self.buttonOpenCustomModal.Height = 25
self.buttonOpenCustomModal.Caption = 'Open'
self.buttonOpenCustomModal.OnClick = self.buttonOpenCustomModalClick
# ==========================================================
# ==========================================================
# BOTTOM OPERATION BUTTONS
self.helpButton = pdk.TGIS_PvlButton(self.Context)
self.helpButton.Top = 130
self.helpButton.Left = 5
self.helpButton.Width = 92
self.helpButton.Height = 25
self.helpButton.Caption = 'Help'
self.helpButton.OnClick = self.helpButtonClick
self.cancelButton = pdk.TGIS_PvlButton(self.Context)
self.cancelButton.Top = 130
self.cancelButton.Left = 100
self.cancelButton.Width = 92
self.cancelButton.Height = 25
self.cancelButton.Caption = 'Cancel'
self.cancelButton.OnClick = self.cancelButtonClick
# ==========================================================
self.OnShow = self.formOnShow
# ==========================================================
# FORM
# ==========================================================
def formOnShow(self, _sender):
print('Printed on show')
self.modalText.SetFocus()
# ==========================================================
# BUTTONS
# ==========================================================
def buttonOpenCustomModalClick(self, _sender):
if self.errorModalButton.Checked:
modalWindow = pdk.TGIS_PvlErrorDialog(self.Context)
elif self.infoModalButton.Checked:
modalWindow = pdk.TGIS_PvlInfoDialog(self.Context)
modalWindow.Text = f'Your text: {self.modalText.Text}'
modalWindow.Title = 'Modal window'
modalWindow.Execute()
def cancelButtonClick(self, _sender):
self.Close()
def helpButtonClick(self, _sender):
webbrowser.open('https://docs.tatukgis.com/EDT5/guide:help:tools:tools')
frm = Form(pdk.GIS)
frm.Show()
def process_event():
pass
pdk.RunPvl(frm, process_event)