[Kr...] Posted October 20, 2022 Share Posted October 20, 2022 Hello, I am trying to create an export script that handles all the various exports our operators have to create after a measure. (STL, PDF, Table, Other Script, Reduced Project etc). The problem is our projects contain multiple keywords where only a couple need changing after each run. The majority of the keywords remain the same, such as CAD Rev Levels, but I still need the operator to check it is correct. What I'm trying to do is create a dialogue box that lists the important keywords. Next to the keywords I would like a button that, if pressed, will open another dialogue box allowing the user to change that specific keyword. For example if the Inspector is incorrect they can press the button and it'll prompt then with a new dialogue box for them to input the correct inspector. Once confirmed this will then update the keyword and return them to the original dialogue box. I've managed to create the initial dialogue box but I am struggling to get an "if, else" button function working. Any help regarding this would be appreciated. I've attached some code for a simpler version of what I am after. Any help would be appreciated. If I can understand how to set the buttons up then I can repeat the process for multiple keywords. DIALOG=gom.script.sys.create_user_defined_dialog (content='<dialog>' \ ' <title>Dialog Title</title>' \ ' <style></style>' \ ' <control id="OkCancel"/>' \ ' <position></position>' \ ' <embedding></embedding>' \ ' <sizemode></sizemode>' \ ' <size width="403" height="257"/>' \ ' <content rows="2" columns="3">' \ ' <widget column="0" rowspan="1" columnspan="1" type="label" row="0">' \ ' <name>label_1</name>' \ ' <tooltip></tooltip>' \ ' <text>Inspector Name</text>' \ ' <word_wrap>false</word_wrap>' \ ' </widget>' \ ' <widget column="1" rowspan="1" columnspan="1" type="display::text" row="0">' \ ' <name>text_1</name>' \ ' <tooltip></tooltip>' \ ' <text><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">' \ '<html><head><meta name="qrichtext" content="1" /><style type="text/css">' \ 'p, li { white-space: pre-wrap; }' \ '</style></head><body style=" ">' \ '<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt; font-style:normal;">$user_Inspector$</span></p></body></html></text>' \ ' <wordwrap>true</wordwrap>' \ ' </widget>' \ ' <widget column="2" rowspan="1" columnspan="1" type="button::pushbutton" row="0">' \ ' <name>Insp_But</name>' \ ' <tooltip></tooltip>' \ ' <text>Change</text>' \ ' <type>push</type>' \ ' <icon_type>none</icon_type>' \ ' <icon_size>icon</icon_size>' \ ' <icon_system_type>ok</icon_system_type>' \ ' <icon_system_size>default</icon_system_size>' \ ' </widget>' \ ' <widget column="0" rowspan="1" columnspan="1" type="label" row="1">' \ ' <name>label</name>' \ ' <tooltip></tooltip>' \ ' <text>Part Name</text>' \ ' <word_wrap>false</word_wrap>' \ ' </widget>' \ ' <widget column="1" rowspan="1" columnspan="1" type="display::text" row="1">' \ ' <name>text</name>' \ ' <tooltip></tooltip>' \ ' <text><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">' \ '<html><head><meta name="qrichtext" content="1" /><style type="text/css">' \ 'p, li { white-space: pre-wrap; }' \ '</style></head><body style=" ">' \ '<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt; font-style:normal;">$user_PartDescription$</span></p></body></html></text>' \ ' <wordwrap>true</wordwrap>' \ ' </widget>' \ ' <widget column="2" rowspan="1" columnspan="1" type="button::pushbutton" row="1">' \ ' <name>Part_But</name>' \ ' <tooltip></tooltip>' \ ' <text>Change</text>' \ ' <type>push</type>' \ ' <icon_type>none</icon_type>' \ ' <icon_size>icon</icon_size>' \ ' <icon_system_type>ok</icon_system_type>' \ ' <icon_system_size>default</icon_system_size>' \ ' </widget>' \ ' </content>' \ '</dialog>') # # Event handler function called if anything happens inside of the dialog # def dialog_event_handler (widget): pass DIALOG.handler = dialog_event_handler RESULT=gom.script.sys.show_user_defined_dialog (dialog=DIALOG) P.s. The other way I've thought of approaching this would be to create a series of text entry fields in the dialogue box but have their default text showing what is already in the project keyword. If that is possible it might be an easier solution as the user can visible see what the keyword is already set as and from the single dialogue box can input the correct information if needed. Any help is, as always, greatly appreciated. Cheers Link to comment Share on other sites More sharing options...
[c2...] Posted October 20, 2022 Share Posted October 20, 2022 You can set the dialog widget values on the dialog initialize event, and can then be used after the dialog closes I made two text input boxes (input_inspector and input_part) and set their values to a user_Inspector and user_PartDescription when the dialog opens. The RESULT.input_inspector and RESULT.input_part will reflect whatever value was in the textbox when the dialog closes # -*- coding: utf-8 -*- import gom DIALOG=gom.script.sys.create_user_defined_dialog (content='<dialog>' \ ' <title>Dialog Title</title>' \ ' <style></style>' \ ' <control id="OkCancel"/>' \ ' <position></position>' \ ' <embedding></embedding>' \ ' <sizemode>fixed</sizemode>' \ ' <size width="345" height="147"/>' \ ' <content columns="2" rows="2">' \ ' <widget column="0" rowspan="1" type="label" row="0" columnspan="1">' \ ' <name>label_1</name>' \ ' <tooltip></tooltip>' \ ' <text>Inspector Name</text>' \ ' <word_wrap>false</word_wrap>' \ ' </widget>' \ ' <widget column="1" rowspan="1" type="input::string" row="0" columnspan="1">' \ ' <name>input_inspector</name>' \ ' <tooltip></tooltip>' \ ' <value></value>' \ ' <read_only>false</read_only>' \ ' </widget>' \ ' <widget column="0" rowspan="1" type="label" row="1" columnspan="1">' \ ' <name>label</name>' \ ' <tooltip></tooltip>' \ ' <text>Part Name</text>' \ ' <word_wrap>false</word_wrap>' \ ' </widget>' \ ' <widget column="1" rowspan="1" type="input::string" row="1" columnspan="1">' \ ' <name>input_part</name>' \ ' <tooltip></tooltip>' \ ' <value></value>' \ ' <read_only>false</read_only>' \ ' </widget>' \ ' </content>' \ '</dialog>') def dialog_event_handler (widget): if widget == 'initialize': DIALOG.input_inspector.value = gom.app.project.user_Inspector DIALOG.input_part.value = gom.app.project.user_PartDescription DIALOG.handler = dialog_event_handler RESULT=gom.script.sys.show_user_defined_dialog (dialog=DIALOG) print('Inspector:', RESULT.input_inspector) print('Part:', RESULT.input_part) Link to comment Share on other sites More sharing options...
[Kr...] Posted October 21, 2022 Author Share Posted October 21, 2022 (edited) Good Morning Robert, I've gave it a trial run and it seems to work perfectly for what I am after. It's taken a bit of tweaking and adapting for the full project I am creating but I should be able to work out any kinks based on what you have provided. Many thanks for your help. Please sign in to view this quote. Edited October 21, 2022 Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in