For the layout I’m not sure how it works… "1/1 <x seems to define a grid layout with one column. You can create composite to have more complex layouts see createComposite(String layout).
I didn’t experiement this issue with your code. When I close the dialog the script continue execution and terminate. Maybe you have something in the code after closing the dialog that prevent the completion of the script.
Firstly I would like to share the way to reach to the documentation of each module:
Help → Help Contents → Scripting User Guide → References → Loadable Modules Reference → System → Voila !!!
Below is a small example of checkbox implementation which would help you undertand how to use callback and how to use checkbox, try to run it in your machine for better understanding:
'''
Created on Jan 20, 2025
@author: Dev
'''
# Placeholder functions for UI controls
def addControl(): pass
def createButton(): pass
def createCheckBox(): pass
def createComboViewer(): pass
def createComparator(): pass
def createComposite(): pass
def createDialog(): pass
def createGroup(): pass
def createImage(): pass
def createLabel(): pass
def createLabelProvider(): pass
def createListViewer(): pass
def createProgressBar(): pass
def createRadioButton(): pass
def createScrolledComposite(): pass
def createSeparator(): pass
def createTableViewer(): pass
def createText(): pass
def createTextBox(): pass
def createTreeViewer(): pass
def createView(): pass
def createViewerColumn(): pass
def getComposite(): pass
def getProviderElement(): pass
def getUiEvent(): pass
def popComposite(): pass
def pushComposite(): pass
def removeControl(): pass
def setColumnCount(): pass
def showGrid(): pass
# Import the system modules to use
loadModule('/System/UI Builder')
# Global variables declaration
list = ['a', 'b', 'c', 'd', 'e'] # List of checkbox labels
checkboxs = [] # List to store checkbox objects
# Callback for select all button
def selectall():
print("Selectall triggered")
for checkbox in checkboxs:
if checkbox.getSelection() == False:
checkbox.setSelection(True)
# Callback for deselect all button
def deselectall():
print("Deselectall triggered")
for checkbox in checkboxs:
if checkbox.getSelection() == True:
checkbox.setSelection(False)
# Creating the main view
createView("Checkbox Explanation")
# Creating checkboxes
for checkbox in list:
checkboxs.append(createCheckBox(f"{checkbox}", False, f'print("checkbox {checkbox} selected")'))
# Creating buttons for select all and deselect all actions
createButton("Select All", "selectall()")
createButton("Deselect All", "deselectall()")
When you read the documentation in the you will see below figure in the UI Builder module:
I tried the index thing you tried to achieve in your code with the minor change in the code provided in above thread:
# Creating checkboxes
index = 1
for checkbox in list:
checkboxs.append(createCheckBox(f"{checkbox}", False, f'print("checkbox {checkbox} selected")', f'1/{index} x'))
index += 1
# Creating buttons for select all and deselect all actions
createButton("Select All", "selectall()")
createButton("Deselect All", "deselectall()")
showGrid()
# Creating checkboxes
pushComposite(createComposite("<")) # set the layout because didn't want the default layout
setColumnCount(2) # You can experiment more with it
for checkbox in list:
checkboxs.append(createCheckBox(f"{checkbox}", False, f'print("checkbox {checkbox} selected")'))
showGrid()
popComposite()
# Creating buttons for select all and deselect all actions
createButton("Select All", "selectall()")
createButton("Deselect All", "deselectall()")
showGrid()
the callback method declared as global instead of instance works! I will now try to implement @Dev 's code with a Dialog and not a View
now that I have all the 4 input parameters for createCheckBox, the layout code works as it should. Probably before I called the placeholder wrongly.
as @Dev pointed out, the script engine is set to be alive after the execution. Do you know how to change this? I tried to getScriptEngine() and terminate it but I get some error: java.lang.reflect.InaccessibleObjectException
When opening a view the script will run until the view is closed. This way the script can handle UI events. In the case of a dialog the script will return (and terminate) when the dialog is closed (OK or Cancel buttons). You can have a look at the view example and the dialog example in the tips and tricks. There are also more advanced examples in the EASE tutorial.
All the examples work. I created some simplier examples and found out:
In the case of a View, I have issues when there are multiple buttons and checkboxes with callback methods. If there is only one of them (only one button, only one checkbox with a callback method), all works correctly. With more of them, the scripts continue running after the View is closed.
In the case of a Dialog, I just solved removing the use of index in build() and evaluate() methods. I don’t know exactly why
[UPDATE] Also with Dialog, multiple cheboxes with callback methods make the script not stopping