Jump to content

Create a dynamic dialog


---
 Share

Recommended Posts

Hello all ,

 Is it possible to create a dynamic dialog? The number of widgets (columns and rows) depends on the user (project)?

Defined by "gom.script.sys.create_user_defined_dialog" only allows to enter a specific number of items, eg checkbox.

Is it possible to edit the dialog window content after its definition (adding more widgets, editing the number of columns and rows) - change the dialog box format?

Link to comment
Share on other sites

It's possible.

For general information about dialog handling (dynamic and static) please have a look at: https://connect.gom.com/x/DZ-VAg

You must define the dialog with parameter "Extendable break dialog" to enable dynamic behavior by the dialog-event-handler.

image.png.b553d7762d2c8764ccafc0bfffc7957f.png

This code just shows a simple example for reference:

import gom

DIALOG=gom.script.sys.create_user_defined_dialog (content='<dialog>' \
' <title>Test Dialog</title>' \
' <style></style>' \
' <control id="OkCancel"/>' \
' <position></position>' \
' <embedding></embedding>' \
' <sizemode></sizemode>' \
' <size width="198" height="191"/>' \
' <content columns="1" rows="4">' \
'  <widget columnspan="1" type="input::checkbox" rowspan="1" row="0" column="0">' \
'   <name>checkbox1</name>' \
'   <tooltip></tooltip>' \
'   <value>true</value>' \
'   <title>Checkbox 1</title>' \
'  </widget>' \
'  <widget columnspan="1" type="input::checkbox" rowspan="1" row="1" column="0">' \
'   <name>checkbox2</name>' \
'   <tooltip></tooltip>' \
'   <value>true</value>' \
'   <title>Checkbox 2</title>' \
'  </widget>' \
'  <widget columnspan="1" type="label" rowspan="1" row="2" column="0">' \
'   <name>text1</name>' \
'   <tooltip></tooltip>' \
'   <text>Text 1</text>' \
'   <word_wrap>false</word_wrap>' \
'  </widget>' \
'  <widget columnspan="1" type="input::string" rowspan="1" row="3" column="0">' \
'   <name>text2</name>' \
'   <tooltip></tooltip>' \
'   <value>Text 2</value>' \
'   <read_only>false</read_only>' \
'   <password>false</password>' \
'  </widget>' \
' </content>' \
'</dialog>')

#
# Event handler function called if anything happens inside of the dialog
#
def dialog_event_handler (widget):
	DIALOG.text1.visible = DIALOG.checkbox1.value
	DIALOG.text2.enabled = DIALOG.checkbox2.value

DIALOG.handler = dialog_event_handler

RESULT=gom.script.sys.show_user_defined_dialog (dialog=DIALOG)

For more information about every single dialog widget you can also use the Python-__doc__-shortcut.

image.png.42b84614eb2042c80c87e18a084b0250.png

Link to comment
Share on other sites

 Share

×
×
  • Create New...