Creating a Custom Interface

Use the Python library Tkinter to create custom GUIs for GisLink addins

TIP: To access SIS API commands, we recommend extending the ‘tkinter.Tk’ class, passing a SIS GisLink object to its __init__ method.

Ensure your extended tkinter.Tk class has its ‘mainloop’ method called by a GisLink event handler; this should be passed as the GisLink event object.

Copy
import  tkinter

...
        
      # Define GUI launch button (in GisLink class __init__)
        self.btn2 = gislink.RibbonButton(text="GUI Launcher",description="Description",help="Help")

        self.btn2.click.add_handler(self.on_click_launch_gui)

        self.application.ribbon_group.add_control(self.btn2)

      def on_click_launch_gui(self, event):
        # Launch GUI (class code below)
        gui = MyGisLinkGUI(event.map_modeller)
        gui.mainloop()


# Custom GUI class, extends tkinter.Tk
class MyGisLinkGUI(tkinter.Tk):
    def __init__(self, sis):
        super().__init__()
        self.sis = sis

        # Force our GUI to top window
        self.wm_attributes("-topmost", 1)


        # Grab some data from the SIS API
        label_text = "SIS Build Number: " + str(self.sis.GetProperty(2,0,"_BuildNumber&"))


     # GUI component definition
        self.label = tkinter.Label(self, text=label_text)
        self.label.pack()