Working with the Ribbon Interface
In-Process GisLink applications are loaded to the “Applications” tab of the SIS Desktop user interface.
Here is an example of a GisLink application (the Routing Tools add-in)
The class has a ribbon group created by default (self.application.ribbon_group).
Individual UI components are added to the ribbon group object. The ribbon group’s label can be changed by setting the “text” attribute on the object.
ribbon_group_text = "Ribbon Group Text" self.application.ribbon_group.text = ribbon_group_text
You can add regular buttons, checkboxes, labels, separators and launch buttons to the ribbon group.
To add a regular button with a click handler:
import gislink
# SIS properties (required)
cadcorp_version = '1.0'
cadcorp_vendor = 'Cadcorp'
class MyGisLinkApp(gislink.Program):
def __init__(self):
super().__init__(name="MyGisLink")
# gislink.Program automatically creates application member
assert self.application is not None
# Set up Ribbon group
self.application.ribbon_group.text = "MyGisLink"
# Add SIS Ribbon controls
btn = gislink.RibbonButton("text")
btn.help = "help"
btn.description = "description"
# Size of button
btn.large_image = True
# Making button visible
btn.min_status = 1 # visible
btn.enabled = True
btn.default_command = True
# Sets button icon to "MyIcon.ico" file located in the same folder as the Python file
#self.btn.icon = os.path.join(os.path.dirname(os.path.abspath(__file__)), "MyIcon.ico")
# Add the button object to the ribbon group
btn.click.add_handler(self.on_click)
self.application.ribbon_group.add_control(btn)
def on_click(self, event):
# Link API to button click
sis = event.desktop
#API ScanOverlay on the highest overlay postion in the current window
scan = sis.ScanOverlay("Items in overlay", (sis.GetInt(4, 0, "_nOverlay&") - 1), "", "")
# Calling predefined variable in print command. Result will be printed in the API & Command Log
print(scan)