Jump to content

Selection element widget with possibility to insert current selected elements


---
 Share

Recommended Posts

Hi, 

I am looking to build a dialog box with a Selection element widget that acts the same as the dropdown menu in the create Element Group function. 

image.png.fa178a28c880ef10bb3b0c46d28be2f1.png

The solutions I am particularly interested in, is:

  • how to implement --- Insert currently selected elements --- from selected elements in the Element Explorer, 
  • and how to implement --- Remove entry ---

Thank you. 

Kind regards,
Emil. 

Link to comment
Share on other sites

  • 4 weeks later...

You can find some documentation about your request here https://connect.gom.com/x/DZ-VAg at point "2.3.13 Selection element widget".

The script snippet you are looking for could be something like:

# -*- coding: utf-8 -*-
		
import gom

DIALOG=gom.script.sys.create_user_defined_dialog (content='<dialog>' \
' <title>Create Element Group</title>' \
' <style></style>' \
' <control id="OkCancel"/>' \
' <position></position>' \
' <embedding></embedding>' \
' <sizemode></sizemode>' \
' <size height="146" width="244"/>' \
' <content columns="2" rows="2">' \
'  <widget row="0" column="0" rowspan="1" type="label" columnspan="1">' \
'   <name>name_lbl</name>' \
'   <tooltip></tooltip>' \
'   <text>Name</text>' \
'   <word_wrap>false</word_wrap>' \
'  </widget>' \
'  <widget row="0" column="1" rowspan="1" type="input::string" columnspan="1">' \
'   <name>name_w</name>' \
'   <tooltip></tooltip>' \
'   <value>Group</value>' \
'   <read_only>false</read_only>' \
'   <password>false</password>' \
'  </widget>' \
'  <widget row="1" column="0" rowspan="1" type="label" columnspan="1">' \
'   <name>element_lbl</name>' \
'   <tooltip></tooltip>' \
'   <text>Elements</text>' \
'   <word_wrap>false</word_wrap>' \
'  </widget>' \
'  <widget row="1" column="1" rowspan="1" type="input::point3d" columnspan="1">' \
'   <name>element_w</name>' \
'   <tooltip></tooltip>' \
'   <supplier>custom</supplier>' \
'  </widget>' \
' </content>' \
'</dialog>')

#
# Event handler function called if anything happens inside of the dialog
#
def dialog_event_handler (widget):
	pass

#
# Element filter function called for all elements to check which ones should be provided for selection in the widget
#
def dialog_element_filter (element):
	try:
		return element.is_selected
	except:
		pass
	return False

DIALOG.handler = dialog_event_handler
DIALOG.element_w.filter = dialog_element_filter

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

 

Link to comment
Share on other sites

  • 2 years later...
  • 3 weeks later...

Please sign in to view this quote.

This is super useful- thanks for posting it

wish i would have seen it earlier 

Edited
Link to comment
Share on other sites

 Share

×
×
  • Create New...